|
@@ -35,16 +35,17 @@ class OrderService
|
|
}
|
|
}
|
|
|
|
|
|
if (!$list->isEmpty()) {
|
|
if (!$list->isEmpty()) {
|
|
- $status = array_column(self::getOrderPayType(),null,'value');
|
|
|
|
- $types = array_column(self::getOrderType(),null,'value');
|
|
|
|
|
|
+ $status = array_column(self::getOrderPayType(), null, 'value');
|
|
|
|
+ $types = array_column(self::getOrderType(), null, 'value');
|
|
foreach ($list as $val) {
|
|
foreach ($list as $val) {
|
|
$val->username = $val->user_id > 0 ? User::where('id', $val->user_id)->value('username') : "";
|
|
$val->username = $val->user_id > 0 ? User::where('id', $val->user_id)->value('username') : "";
|
|
$val->company_name = "-";
|
|
$val->company_name = "-";
|
|
$val->play_name = '-';
|
|
$val->play_name = '-';
|
|
$company = Miniprogram::where('id', $val->miniprogram_id)->first();
|
|
$company = Miniprogram::where('id', $val->miniprogram_id)->first();
|
|
if ($company) {
|
|
if ($company) {
|
|
- $val->company_name = $company->company();
|
|
|
|
|
|
+ $val->company_name = $val->puser_id > 0 ? $company->company() : "-";
|
|
$val->play_name = $company->play_name;
|
|
$val->play_name = $company->play_name;
|
|
|
|
+ $val->xcx_name = $company->name;
|
|
}
|
|
}
|
|
$val->promotion_title = $val->promotion_id > 0 ? DB::table('promotions')->where('id', $val->promotion_id)->value('name') : "";
|
|
$val->promotion_title = $val->promotion_id > 0 ? DB::table('promotions')->where('id', $val->promotion_id)->value('name') : "";
|
|
$val->total_count = Order::where('uid', $val->uid)->where('id', "<=", $val->id)->count();
|
|
$val->total_count = Order::where('uid', $val->uid)->where('id', "<=", $val->id)->count();
|
|
@@ -55,7 +56,7 @@ class OrderService
|
|
$val->caompany_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->count();
|
|
$val->caompany_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->count();
|
|
$val->promotion_count = Order::where('uid', $val->uid)->where('user_id', '>', 0)->count();
|
|
$val->promotion_count = Order::where('uid', $val->uid)->where('user_id', '>', 0)->count();
|
|
}
|
|
}
|
|
- $val->tip_text = $types[$val->order_type]['name']?? "-";
|
|
|
|
|
|
+ $val->tip_text = $types[$val->order_type]['name'] ?? "-";
|
|
$val->status_txt = $status[$val->status]['name'] ?? "-";
|
|
$val->status_txt = $status[$val->status]['name'] ?? "-";
|
|
$val->pay_name = '微信支付';
|
|
$val->pay_name = '微信支付';
|
|
}
|
|
}
|
|
@@ -67,20 +68,20 @@ class OrderService
|
|
public static function getOrderType()
|
|
public static function getOrderType()
|
|
{
|
|
{
|
|
return [
|
|
return [
|
|
- ["value" => "COIN","name" => "普通充值"],
|
|
|
|
- ["value" => 'MONTH',"name" => '包月'],
|
|
|
|
- ["value" => 'QUARTER' ,"name"=> '包季'],
|
|
|
|
- ["value" => 'YEAR' ,"name"=> '包年'],
|
|
|
|
- ["value" => "FIRST_COIN" ,"name" => "首充"]
|
|
|
|
|
|
+ ["value" => "COIN", "name" => "普通充值"],
|
|
|
|
+ ["value" => 'MONTH', "name" => '包月'],
|
|
|
|
+ ["value" => 'QUARTER', "name" => '包季'],
|
|
|
|
+ ["value" => 'YEAR', "name" => '包年'],
|
|
|
|
+ ["value" => "FIRST_COIN", "name" => "首充"]
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
public static function getOrderPayType()
|
|
public static function getOrderPayType()
|
|
{
|
|
{
|
|
return [
|
|
return [
|
|
- ["value" => "PAID","name" => "已支付"],
|
|
|
|
- ["value" =>'REFUND',"name" => '已退款'],
|
|
|
|
- ["value" =>'UNPAID' ,"name"=> '未支付'],
|
|
|
|
|
|
+ ["value" => "PAID", "name" => "已支付"],
|
|
|
|
+ ["value" => 'REFUND', "name" => '已退款'],
|
|
|
|
+ ["value" => 'UNPAID', "name" => '未支付'],
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -151,20 +152,26 @@ class OrderService
|
|
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
|
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
|
* date 2023/05/23 17:51
|
|
* date 2023/05/23 17:51
|
|
*/
|
|
*/
|
|
- public static function userUseProgramsList(mixed $uid)
|
|
|
|
|
|
+ public static function userUseProgramsList(mixed $uid, $name = "", $limit = 20)
|
|
{
|
|
{
|
|
|
|
|
|
$operateUser = User::find($uid);
|
|
$operateUser = User::find($uid);
|
|
$operateUserRoles = $operateUser->roles->pluck('identify');
|
|
$operateUserRoles = $operateUser->roles->pluck('identify');
|
|
-
|
|
|
|
if ($operateUserRoles->contains('company') || $operateUserRoles->contains('optimizer')) {
|
|
if ($operateUserRoles->contains('company') || $operateUserRoles->contains('optimizer')) {
|
|
- return UserHasMiniprograms::query()->join('miniprogram', 'miniprogram.id', '=', 'user_has_miniprograms.miniprogram_id')
|
|
|
|
|
|
+ $list = UserHasMiniprograms::query()->join('miniprogram', 'miniprogram.id', '=', 'user_has_miniprograms.miniprogram_id')
|
|
->where('uid', $uid)
|
|
->where('uid', $uid)
|
|
->groupBy("user_has_miniprograms.miniprogram_id")
|
|
->groupBy("user_has_miniprograms.miniprogram_id")
|
|
- ->select('user_has_miniprograms.miniprogram_id', 'miniprogram.name', 'miniprogram.play_name')
|
|
|
|
- ->get();
|
|
|
|
|
|
+ ->select('user_has_miniprograms.miniprogram_id', 'miniprogram.name', 'miniprogram.play_name');
|
|
|
|
+ if ($name) {
|
|
|
|
+ $list->where('name', "like", "%" . $name . "%");
|
|
|
|
+ }
|
|
|
|
+ return $list->orderBy('miniprogram.id', 'desc')->limit($limit)->get();
|
|
} else {
|
|
} else {
|
|
- return DB::table('miniprogram')->select("id as miniprogram_id", "name", "play_name")->get();
|
|
|
|
|
|
+ if ($name) {
|
|
|
|
+ return DB::table('miniprogram')->where('name', "like", "%" . $name . "%")->select("id as miniprogram_id", "name", "play_name")->limit($limit)->get();
|
|
|
|
+ }
|
|
|
|
+ return DB::table('miniprogram')->select("id as miniprogram_id", "name", "play_name")->orderBy('id', 'desc')->limit($limit)->get();
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -177,29 +184,74 @@ class OrderService
|
|
* @return \Illuminate\Support\Collection
|
|
* @return \Illuminate\Support\Collection
|
|
* date 2023/05/23 18:13
|
|
* date 2023/05/23 18:13
|
|
*/
|
|
*/
|
|
- public static function promotionsOptions(mixed $uid, mixed $title)
|
|
|
|
|
|
+ public static function promotionsOptions(mixed $uid, mixed $title,mixed $miniprogram_id,mixed $limit = 10)
|
|
{
|
|
{
|
|
$operateUser = User::find($uid);
|
|
$operateUser = User::find($uid);
|
|
$operateUserRoles = $operateUser->roles->pluck('identify');
|
|
$operateUserRoles = $operateUser->roles->pluck('identify');
|
|
- $list = DB::table('promotions')->select('id as promotion_id ', 'name');
|
|
|
|
|
|
+ $list = DB::table('promotions')->select('id as promotion_id', 'name');
|
|
if ($operateUserRoles->contains('optimizer')) {
|
|
if ($operateUserRoles->contains('optimizer')) {
|
|
|
|
+ if ($miniprogram_id){
|
|
|
|
+ $list->where('miniprogram_id',$miniprogram_id);
|
|
|
|
+ }
|
|
if ($title) {
|
|
if ($title) {
|
|
$list->where('name', 'like', "%" . $title . "%");
|
|
$list->where('name', 'like', "%" . $title . "%");
|
|
}
|
|
}
|
|
- return $list->where('uid', $uid)->get();
|
|
|
|
|
|
+
|
|
|
|
+ return $list->where('uid', $uid)->orderBy('id', 'desc')->limit($limit)->get();
|
|
} else if ($operateUserRoles->contains('company')) {
|
|
} else if ($operateUserRoles->contains('company')) {
|
|
- $list = DB::table('promotions')->join('users','users.id',"promotions.uid")
|
|
|
|
- ->where('users.pid',$uid)->orWhere("promotions.uid",$uid)->select("promotions.id as promotion_id ", 'promotions.name');
|
|
|
|
|
|
+ $list = DB::table('promotions')->join('users', 'users.id', "promotions.uid")
|
|
|
|
+ ->where('users.pid', $uid)->orWhere("promotions.uid", $uid)->select('promotions.id as promotion_id', 'promotions.name');
|
|
if ($title) {
|
|
if ($title) {
|
|
$list->where('promotions.name', 'like', "%" . $title . "%");
|
|
$list->where('promotions.name', 'like', "%" . $title . "%");
|
|
}
|
|
}
|
|
- return $list->get();
|
|
|
|
|
|
+ if ($miniprogram_id){
|
|
|
|
+ $list->where('promotions.miniprogram_id',$miniprogram_id);
|
|
|
|
+ }
|
|
|
|
+ return $list->orderBy('promotions.id','desc')->limit($limit)->get();
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+ if ($miniprogram_id){
|
|
|
|
+ $list->where('miniprogram_id',$miniprogram_id);
|
|
|
|
+ }
|
|
if ($title) {
|
|
if ($title) {
|
|
$list->where('name', 'like', "%" . $title . "%");
|
|
$list->where('name', 'like', "%" . $title . "%");
|
|
}
|
|
}
|
|
- return $list->get();
|
|
|
|
|
|
+ return $list->orderBy('id', 'desc')->limit($limit)->get();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /***
|
|
|
|
+ * 订单列表优化师选择项
|
|
|
|
+ * name: promotionsUsers
|
|
|
|
+ * @param mixed $pid
|
|
|
|
+ * @param mixed $name
|
|
|
|
+ * @param mixed $limit
|
|
|
|
+ * date 2023/05/26 09:22
|
|
|
|
+ */
|
|
|
|
+ public static function promotionsUsers(mixed $pid, mixed $name,mixed $miniprogram_id, mixed $limit = 10)
|
|
|
|
+ {
|
|
|
|
+ if ($pid > 0) {
|
|
|
|
+ $list = DB::table('users')->where('pid', $pid)->select('users.id as user_id', 'users.username as name');
|
|
|
|
+ if ($name) {
|
|
|
|
+ $list->where('username', 'like', "%" . $name . "%");
|
|
|
|
+ }
|
|
|
|
+ if ($miniprogram_id > 0){
|
|
|
|
+ $list->join('user_has_miniprograms','user_has_miniprograms.uid','users.id')
|
|
|
|
+ ->where('user_has_miniprograms.miniprogram_id',$miniprogram_id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $list->orderBy('users.id', 'desc')->limit($limit)->get();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $list = DB::table('users')->join('user_has_roles','users.id',"user_has_roles.user_id")->join('roles','roles.id','user_has_roles.role_id')
|
|
|
|
+ ->select('users.id as user_id', 'users.username as name')->where('roles.identify','optimizer');
|
|
|
|
+ if ($miniprogram_id > 0){
|
|
|
|
+ $list->join('user_has_miniprograms','user_has_miniprograms.uid','users.id')
|
|
|
|
+ ->where('user_has_miniprograms.miniprogram_id',$miniprogram_id);
|
|
|
|
+ }
|
|
|
|
+ if ($name){
|
|
|
|
+ $list->where('users.username', 'like', "%" . $name . "%");
|
|
}
|
|
}
|
|
|
|
+ return $list->orderBy('users.id', 'desc')->limit($limit)->get();
|
|
}
|
|
}
|
|
}
|
|
}
|