|
@@ -404,31 +404,32 @@ class CronLogic extends BaseLogic
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- //3.获取已结算订单,并通知
|
|
|
+ //3.获取上月已结算订单,并通知
|
|
|
$completeOrders = UserOrderCommissionModel::query()
|
|
|
->where("commission_status",1)
|
|
|
->where("order_commission",">",0)
|
|
|
->where("user_id","<>",0)
|
|
|
->where("order_complete_notify_status",0)
|
|
|
- ->limit(10)
|
|
|
+ ->groupBy("user_id")
|
|
|
+ ->select(["user_id",DB::Raw("sum(order_commission) as total_order_commission"),DB::Raw("GROUP_CONCAT(id) as ids")])
|
|
|
->get();
|
|
|
+
|
|
|
foreach ($completeOrders as $order){
|
|
|
$user = UserModel::findById($order->user_id);
|
|
|
if($user){
|
|
|
try{
|
|
|
//获取公众号实例
|
|
|
$app = WechatAccountUtil::getAppByID($user->wechat_account_id);
|
|
|
- $tmpOrder = UserOrderModel::query()->where("order_number",$order->order_number)->first();
|
|
|
$data = [
|
|
|
'touser' => $user->user_open_id,
|
|
|
'template_id' => env("WECHAT_COMPLETE_ORDER_TEMPLATE_URL"),
|
|
|
'url' => env("WECHAT_BALANCE_URL"),
|
|
|
'data' => [
|
|
|
- 'first' => "订单:[".$tmpOrder["order_number"]."]佣金已结算完成",
|
|
|
- 'keyword1' => round($order->order_commission/100,2)."元",
|
|
|
- 'keyword2' => round($tmpOrder->order_price/100,2)."元",
|
|
|
- 'keyword3' => $order->updated_at,
|
|
|
- "remark"=>"订单佣金已结算完成,感谢您的使用,点击详情跳转我的账户"
|
|
|
+ 'first' => "上月订单佣金已结算完成",
|
|
|
+ 'keyword1' => round($order["total_order_commission"]/100,2)."元",
|
|
|
+ 'keyword2' => round($order["total_order_commission"]/100,2)."元",
|
|
|
+ 'keyword3' => date("Y-m-d H:i:s"),
|
|
|
+ "remark"=>"订单佣金已结算完成,可以立即提现哦!零钱秒到账"
|
|
|
],
|
|
|
];
|
|
|
$res = $app->template_message->send($data);
|
|
@@ -437,7 +438,7 @@ class CronLogic extends BaseLogic
|
|
|
$instance->info("订单结算通知结果异常:".$exception->getMessage());
|
|
|
}
|
|
|
}
|
|
|
- UserOrderCommissionModel::query()->where("id",$order->id)->update(
|
|
|
+ UserOrderCommissionModel::query()->whereIn("id",explode(",",$order["ids"]))->update(
|
|
|
[
|
|
|
"order_complete_notify_status"=>1
|
|
|
]
|