mark 3 gadi atpakaļ
vecāks
revīzija
32a399cfd9

+ 12 - 0
app/Http/Controllers/BaseController.php

@@ -23,9 +23,11 @@ use App\Http\Utils\Pdd\DuoDuoKeUtil;
 use App\Http\Utils\TaoBao\TaobaoLianMengUtil;
 use App\Http\Utils\Wechat\Miniprograme\MiniprogrameLianMengUtil;
 use App\Http\Utils\WechatAccountUtil;
+use App\Models\UserOrderCommissionModel;
 use App\Models\WechatAccountModel;
 use EasyWeChat\Kernel\Messages\Image;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
 use Tool\ShanTaoTool\Bean\Pdd\Ddk\ResourceUrlGenParamBean;
 use Tool\ShanTaoTool\Pdd\Ddk\DdkDaogouService;
 
@@ -128,6 +130,16 @@ class BaseController extends Controller
 
     public function test()
     {
+        $completeOrders = UserOrderCommissionModel::query()
+            ->where("commission_status",1)
+            ->where("order_commission",">",0)
+            ->where("user_id","<>",0)
+            ->where("order_complete_notify_status",0)
+            ->groupBy("user_id")
+            ->select(["user_id",DB::Raw("sum(order_commission) as total_order_commission"),DB::Raw("GROUP_CONCAT(id) as ids")])
+            ->get();
+        return $this->success($completeOrders);
+//        return $this->success(JutuikeUtil::getActList());
 //        TaobaoLianMengUtil::taokoulingConvert("淘宝,信这于好之他而着我而天到微喜【sheii苏茵茵】大小姐~韩国真皮粗跟中筒靴女秋弹力长靴瘦腿靴");
         TaobaoLianMengUtil::taokoulingConvert("89!就心也对他可大能们后小哈 https://m.tb.cn/h.fgXlN6a?sm=3efae5  儿童过家家小医生玩具套装仿真医疗箱女孩护士打针男孩听诊器工具");
 //        $data = JutuikeUtil::goodsCategory("jd");

+ 10 - 9
app/Http/Logic/Cron/CronLogic.php

@@ -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
                 ]