|
@@ -11,6 +11,7 @@ namespace Modules\Channel\Services\Order;
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Modules\Channel\Models\Order;
|
|
use Modules\Channel\Models\Order;
|
|
|
|
+use Modules\Channel\Models\UserHasMiniprograms;
|
|
use Modules\Manage\Models\Miniprogram;
|
|
use Modules\Manage\Models\Miniprogram;
|
|
use Modules\User\Models\User;
|
|
use Modules\User\Models\User;
|
|
|
|
|
|
@@ -35,8 +36,10 @@ class OrderService
|
|
|
|
|
|
|
|
|
|
if (!$list->isEmpty()) {
|
|
if (!$list->isEmpty()) {
|
|
|
|
+ $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();
|
|
@@ -45,16 +48,16 @@ class OrderService
|
|
$val->play_name = $company->play_name;
|
|
$val->play_name = $company->play_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();
|
|
|
|
- if ($val->user_id > 0){
|
|
|
|
- $val->caompany_count = Order::where('uid',$val->uid)->where('puser_id','>',0)->where('puser_id',$val->puser_id)->where('id',"<=",$val->id)->count();
|
|
|
|
- $val->promotion_count = Order::where('uid',$val->uid)->where('puser_id','>',0)->where('puser_id',$val->puser_id)->where('user_id',">",0)->where('user_id',$val->user_id)->where('id',"<=",$val->id)->count();
|
|
|
|
- }else{
|
|
|
|
- $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->total_count = Order::where('uid', $val->uid)->where('id', "<=", $val->id)->count();
|
|
|
|
+ if ($val->user_id > 0) {
|
|
|
|
+ $val->caompany_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->where('puser_id', $val->puser_id)->where('id', "<=", $val->id)->count();
|
|
|
|
+ $val->promotion_count = Order::where('uid', $val->uid)->where('puser_id', '>', 0)->where('puser_id', $val->puser_id)->where('user_id', ">", 0)->where('user_id', $val->user_id)->where('id', "<=", $val->id)->count();
|
|
|
|
+ } else {
|
|
|
|
+ $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->tip_text = self::getOrderType()[$val->order_type] ?? "-";
|
|
|
|
- $val->status_txt = self::getOrderPayType()[$val->status] ?? "-";
|
|
|
|
|
|
+ $val->tip_text = $types[$val->order_type]['name']?? "-";
|
|
|
|
+ $val->status_txt = $status[$val->status]['name'] ?? "-";
|
|
$val->pay_name = '微信支付';
|
|
$val->pay_name = '微信支付';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -62,20 +65,23 @@ class OrderService
|
|
return $list;
|
|
return $list;
|
|
}
|
|
}
|
|
|
|
|
|
- public static function getOrderType(){
|
|
|
|
|
|
+ public static function getOrderType()
|
|
|
|
+ {
|
|
return [
|
|
return [
|
|
- "COIN" => "普通充值",
|
|
|
|
- 'MONTH'=>'包月',
|
|
|
|
- 'QUARTER'=>'包季',
|
|
|
|
- 'YEAR'=>'包年',
|
|
|
|
- "FIRST_COIN" => "首冲"
|
|
|
|
|
|
+ ["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 [
|
|
- "PAID" => "已支付",
|
|
|
|
- 'REFUND'=>'已退款',
|
|
|
|
- 'UNPAID'=>'未支付',
|
|
|
|
|
|
+ ["value" => "PAID","name" => "已支付"],
|
|
|
|
+ ["value" =>'REFUND',"name" => '已退款'],
|
|
|
|
+ ["value" =>'UNPAID' ,"name"=> '未支付'],
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,13 +127,80 @@ class OrderService
|
|
// $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%");
|
|
// $sql->where('trade_no', "like", "%" . $param['trade_no'] . "%");
|
|
$sql->where('trade_no', $param['trade_no']);
|
|
$sql->where('trade_no', $param['trade_no']);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // 支付时间
|
|
if (!empty(getProp($param, 'pay_end_at_start'))) {
|
|
if (!empty(getProp($param, 'pay_end_at_start'))) {
|
|
$sql->where('pay_end_at', $param['pay_end_at_start']);
|
|
$sql->where('pay_end_at', $param['pay_end_at_start']);
|
|
}
|
|
}
|
|
if (!empty(getProp($param, 'pay_end_at_end'))) {
|
|
if (!empty(getProp($param, 'pay_end_at_end'))) {
|
|
$sql->where('pay_end_at', "<=", $param['pay_end_at_end']);
|
|
$sql->where('pay_end_at', "<=", $param['pay_end_at_end']);
|
|
}
|
|
}
|
|
|
|
+ // 创建时间
|
|
|
|
+ if (!empty(getProp($param, 'created_at_start'))) {
|
|
|
|
+ $sql->where('created_at', $param['created_at_start']);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!empty(getProp($param, 'created_at_end'))) {
|
|
|
|
+ $sql->where('created_at', "<=", $param['created_at_end']);
|
|
|
|
+ }
|
|
return $sql;
|
|
return $sql;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 用户订单小程选择列表
|
|
|
|
+ * name: userUseProgramsList
|
|
|
|
+ * @param mixed $uid
|
|
|
|
+ * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
|
|
|
+ * date 2023/05/23 17:51
|
|
|
|
+ */
|
|
|
|
+ public static function userUseProgramsList(mixed $uid)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $operateUser = User::find($uid);
|
|
|
|
+ $operateUserRoles = $operateUser->roles->pluck('identify');
|
|
|
|
+
|
|
|
|
+ if ($operateUserRoles->contains('company') || $operateUserRoles->contains('optimizer')) {
|
|
|
|
+ return UserHasMiniprograms::query()->join('miniprogram', 'miniprogram.id', '=', 'user_has_miniprograms.miniprogram_id')
|
|
|
|
+ ->where('uid', $uid)
|
|
|
|
+ ->groupBy("user_has_miniprograms.miniprogram_id")
|
|
|
|
+ ->select('user_has_miniprograms.miniprogram_id', 'miniprogram.name', 'miniprogram.play_name')
|
|
|
|
+ ->get();
|
|
|
|
+ } else {
|
|
|
|
+ return DB::table('miniprogram')->select("id as miniprogram_id", "name", "play_name")->get();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推广列表选择项
|
|
|
|
+ * name: promotionsOptions
|
|
|
|
+ * @param mixed $uid
|
|
|
|
+ * @param mixed $title
|
|
|
|
+ * @return \Illuminate\Support\Collection
|
|
|
|
+ * date 2023/05/23 18:13
|
|
|
|
+ */
|
|
|
|
+ public static function promotionsOptions(mixed $uid, mixed $title)
|
|
|
|
+ {
|
|
|
|
+ $operateUser = User::find($uid);
|
|
|
|
+ $operateUserRoles = $operateUser->roles->pluck('identify');
|
|
|
|
+ $list = DB::table('promotions')->select('id as promotion_id ', 'name');
|
|
|
|
+ if ($operateUserRoles->contains('optimizer')) {
|
|
|
|
+ if ($title) {
|
|
|
|
+ $list->where('name', 'like', "%" . $title . "%");
|
|
|
|
+ }
|
|
|
|
+ return $list->where('uid', $uid)->get();
|
|
|
|
+ } 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');
|
|
|
|
+ if ($title) {
|
|
|
|
+ $list->where('promotions.name', 'like', "%" . $title . "%");
|
|
|
|
+ }
|
|
|
|
+ return $list->get();
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ if ($title) {
|
|
|
|
+ $list->where('name', 'like', "%" . $title . "%");
|
|
|
|
+ }
|
|
|
|
+ return $list->get();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|