Explorar o código

公证处 &图片

xialei hai 1 ano
pai
achega
056a2d0e8a

+ 26 - 0
app/controller/admin/system/merchant/GzcLogs.php

@@ -118,6 +118,19 @@ class GzcLogs extends BaseController
118 118
             'success' => 1,
119 119
             'update_time' => date('Y-m-d H:i:s')
120 120
         ]);
121
+
122
+        //发起成功更新记录值
123
+        $order_id = Db::name('store_order')->where('order_sn', $log['out_trade_no'])->value('order_id');
124
+        if($order_id){
125
+            $bill = Db::name('user_bill')->where('link_id', $order_id)->where('commission_type', 5)->where('is_gzc', 'in', [0, 1])->find();
126
+            if($bill){
127
+                Db::name('user_bill')
128
+                ->where('bill_id', $bill['bill_id'])
129
+                ->update([
130
+                    'is_gzc' => 2
131
+                ]);
132
+            }
133
+        }
121 134
         
122 135
         return app('json')->success('发起成功', $log);
123 136
     }
@@ -186,6 +199,19 @@ class GzcLogs extends BaseController
186 199
                 'success' => 1,
187 200
                 'update_time' => date('Y-m-d H:i:s')
188 201
             ]);
202
+
203
+            //发起成功更新记录值
204
+            $order_id = Db::name('store_order')->where('order_sn', $log['out_trade_no'])->value('order_id');
205
+            if($order_id){
206
+                $bill = Db::name('user_bill')->where('link_id', $order_id)->where('commission_type', 5)->where('is_gzc', 'in', [0, 1])->find();
207
+                if($bill){
208
+                    Db::name('user_bill')
209
+                    ->where('bill_id', $bill['bill_id'])
210
+                    ->update([
211
+                        'is_gzc' => 2
212
+                    ]);
213
+                }
214
+            }
189 215
         }
190 216
         return app('json')->success('发起成功');
191 217
     }

+ 200 - 4
app/controller/api/cron/CommissionCron.php

@@ -3,7 +3,9 @@
3 3
 
4 4
 namespace app\controller\api\cron;
5 5
 
6
-
6
+use app\common\model\store\order\StoreOrder;
7
+use app\common\repositories\user\UserBillRepository;
8
+use app\common\model\user\UserCertification;
7 9
 use AdaPaySdk\Drawcash;
8 10
 use AdaPaySdk\PaymentConfirm;
9 11
 use AdaPaySdk\SettleAccount;
@@ -27,6 +29,7 @@ use think\facade\Cache;
27 29
 use think\facade\Db;
28 30
 use think\facade\Log;
29 31
 use function GuzzleHttp\Psr7\str;
32
+use app\traits\HuiPay;
30 33
 
31 34
 class CommissionCron
32 35
 {
@@ -1303,10 +1306,203 @@ where o.paid=1 and o.is_settlement=1 and settlement_time between '$this->startMo
1303 1306
         $this->sendEMail(['389123492@qq.com', '420132441@qq.com'], '结算定时', "执行结束<br/>" . $mallStr . date('Y-m-d H:i:s'), '如果邮件客户端不支持HTML则显示此内容');
1304 1307
     }
1305 1308
 
1306
-
1309
+    use HuiPay;
1307 1310
 
1308 1311
     public function cesexx(){
1309
-        // $storeOrderRepository = app()->make(StoreOrderRepository::class);
1310
-        // $storeOrderRepository->douhuomall_delivery();
1312
+
1313
+        // 普通订单
1314
+        $cursor = Db::table('rrx_store_order')->where('paid', 1)->where('gzc', 0)->where('mer_id', 496)->where('pay_type', 'in', [0,1,2,4])->select();
1315
+        $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
1316
+        $OrderMerchantRepository    = app()->make(OrderMerchantRepository::class);
1317
+        $OrderGzcRepository         = app()->make(OrderGzcRepository::class);
1318
+        foreach ($cursor as $online) {
1319
+            if ($online['mer_id'] == 496) {
1320
+                if (!in_array($online['status'], [0, 1, 2, 3])) {
1321
+                    continue;
1322
+                }
1323
+            }
1324
+
1325
+            $certification = UserCertification::getInstance()->where('uid', $online['uid'])->find();
1326
+            if (!$certification) {
1327
+                Log::info($online['uid'] . '没有实名认证');
1328
+                // echo '没有实名认证';
1329
+                continue;
1330
+            }
1331
+            //查询养老金金额
1332
+            $UserBillRepository = app()->make(UserBillRepository::class);
1333
+            $bill               = $UserBillRepository->getWhere(['uid' => $online['uid'], 'link_id' => $online['order_id'], 'commission_type' => 5]);
1334
+
1335
+            $pension = $bill->number ?? 0;
1336
+            if ($pension <= 0) {
1337
+                echo '金额为为0:'.$online['order_sn'];
1338
+                Log::info($online['order_sn'] . 'pension' . $pension);
1339
+                continue;
1340
+            }
1341
+
1342
+            Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository) {
1343
+                //新增入账明细记录
1344
+                $orderId   = $OrderMerchantRepository->getNewOrderId('IN10');
1345
+                $create    = [
1346
+                    'uid'          => $online['uid'],
1347
+                    'platform_no'  => $orderId,
1348
+                    'account_type' => $online['pay_type'] == 1 ? 3 : 2,
1349
+                    'user_name'    => $certification['user_name'],
1350
+                    'mobile'       => $certification['mobile'],
1351
+                    'user_card'    => $certification['user_card'],
1352
+                    'pension'      => $pension,
1353
+                    'order_type'   => 2,
1354
+                    'out_trade_no' => $online['order_sn']
1355
+                ];
1356
+                $test_user = Db::name('user')->where('uid', $online['uid'])->value('test_user');
1357
+                $check     = Db::name("gzc_logs")->where("out_trade_no", $online['order_sn'])->where("order_type", 2)->count();
1358
+                if ($test_user == 0 && $check <= 0) {
1359
+                    $OrderGzcRepository->create($create);
1360
+                }
1361
+                $order                  = StoreOrder::getInstance()->find($online['order_id']);
1362
+                $order->gzc             = 1;
1363
+                $order->save();
1364
+            });
1365
+
1366
+            $bill->gzc = 1;
1367
+            $bill->is_gzc = 1;
1368
+            $bill->save();
1369
+        }
1370
+
1371
+
1372
+        
1373
+        //18995126502
1374
+       //会员直推荐佣金补1800,复购金补200,贡献值补4900,积分补4900,养老金补350
1375
+
1376
+    //    $user = Db::name("user")->where('uid', 910)->find();
1377
+
1378
+
1379
+    //    $order_sn = 0;
1380
+    //    $order_id = 0;
1381
+    //    $order["mer_id"] = 0;
1382
+
1383
+    //    //sat存养老金
1384
+    //    $tuiguanyanglaojin = '350';
1385
+    //    $tuimark = "推荐消费获得养老金" . $tuiguanyanglaojin;
1386
+    //    $tuititle = "养老金";
1387
+    //    $commission_type = 5;
1388
+    //    if ($tuiguanyanglaojin >= 0.01) {
1389
+    //        $this->add_bill($tuititle, $tuiguanyanglaojin, $user["uid"], $tuimark, $commission_type, $order_sn, $order_id, $order["mer_id"], 0, 0, 0);
1390
+    //    } else {
1391
+    //        Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低,推荐养老金低于0.01无法入库 特此记录!']);
1392
+    //    }
1393
+
1394
+    //    $tuiguanyongjin = '1800';
1395
+    //    $tuiYongmark = "推荐消费获得佣金" . $tuiguanyongjin;
1396
+    //    $tuiYongzhoutitle = "推广佣金";
1397
+    //    $commission_yong_type = 3;
1398
+    //    if ($tuiguanyongjin >= 0.01) {
1399
+    //        $this->add_bill($tuiYongzhoutitle, $tuiguanyongjin, $user["uid"], $tuiYongmark, $commission_yong_type, $order_sn, $order_id, $order["mer_id"], 0, 0, 0);
1400
+    //    } else {
1401
+    //        Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,佣金低于0.01无法入库 特此记录!']);
1402
+    //    }
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+        // $merchant_member_list = Db::name('order_merchant')
1411
+        //            ->where('status', 0)->where('paid', 0)->where('create_time', '>', '2025-01-01 00:00:00')
1412
+        //             ->column('id,mer_id,uid,out_trade_no,hf_pay_id,create_time');
1413
+        // $out_trade_no_list = [];
1414
+        // foreach ($merchant_member_list as $key => $value) {
1415
+        //     if (strpos($value['out_trade_no'], 'ALI') !== false) {
1416
+        //         //支付宝
1417
+        //         $api_key = 'api_live_b23537ed-64b8-45d6-832e-fb228aa9e0a9';
1418
+        //     } else {
1419
+        //         //微信
1420
+        //         $api_key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
1421
+        //     }
1422
+
1423
+        //     $params = [
1424
+        //         'api_key'    => $api_key,
1425
+        //         'payment_id'    => $value['hf_pay_id'],
1426
+        //     ];
1427
+            
1428
+        //     $res = $this->Payment_query_traits($params);
1429
+
1430
+        //     if (isset($res['status']) && $res['status'] == 'succeeded') {
1431
+        //         $params['out_trade_no'] = $value['out_trade_no'];
1432
+        //         // echo json_encode($params);
1433
+        //         $out_trade_no_list[] =  $value['out_trade_no'];
1434
+        //     }
1435
+
1436
+        //     echo json_encode($res);
1437
+        //     $params['out_trade_no'] = $value['out_trade_no'];
1438
+        //     echo json_encode($params);
1439
+        // }
1440
+        // echo json_encode($out_trade_no_list);
1441
+        // $api_key = 'api_live_b0a687ec-5450-4ada-a0e4-65bac0f46871';
1442
+        // $params = [
1443
+        //     'api_key'    => $api_key,
1444
+        //     'payment_id'    => '002212025031014345810745060317006163968'
1445
+        // ];  
1446
+        
1447
+        // $res = $this->Payment_query_traits($params);
1448
+        // echo json_encode($res);
1449
+        // $params['out_trade_no'] = $value['out_trade_no'];
1450
+        // echo json_encode($params);
1451
+
1452
+
1453
+        // echo json_encode($merchant_member_list);
1454
+        // echo 'xxx';
1455
+    }
1456
+
1457
+
1458
+        /**
1459
+     * 佣金加入账单
1460
+     * @param $title
1461
+     * @param $number
1462
+     * @param $uid
1463
+     * @param $mark
1464
+     * @param $commission_type
1465
+     * @param $order_sn
1466
+     */
1467
+    public function add_bill($title, $number, $uid, $mark, $commission_type, $order_sn, $order_id = 0, $mer_id = 0, $source = 0, $status = 1, $type_shop = 0)
1468
+    {
1469
+        log::info("====进入add——bill");
1470
+        log::info("==uid==={$uid}");
1471
+        if ($uid == 0 || $number == 0) {
1472
+            return;
1473
+        }
1474
+
1475
+        $number = sprintf('%.2f', $number);
1476
+
1477
+        $data = [
1478
+            'link_id' => $order_id,
1479
+            "uid" => $uid,
1480
+            "pm" => 1,
1481
+            "title" => $title,
1482
+            "category" => "now_money",
1483
+            "type" => "commission",
1484
+            "number" => $number,
1485
+            "balance" => 0,
1486
+            "mark" => $mark,
1487
+            //            "create_time"=>date("Y-m-d H:i:s"),
1488
+            "status" => $status,
1489
+            "commission_type" => $commission_type,
1490
+            "order_sn" => $order_sn,
1491
+            "mer_id" => $mer_id,
1492
+            "source" => $source,
1493
+            "type_shop" => $type_shop
1494
+        ];
1495
+        log::info("开始添加user——bills");
1496
+        log::info($data);
1497
+        Db::name("user_bill")->insert($data);
1498
+
1499
+        if ($type_shop == 0) {
1500
+           if ($commission_type == 5) {
1501
+               Db::name("user")->where("uid", $uid)->inc('annuity', $number)->update();
1502
+               Db::name("user")->where("uid", $uid)->inc('annuity_num', 1)->update();
1503
+           } else {
1504
+               Db::name("user")->where("uid", $uid)->inc('brokerage_price', $number)->update();
1505
+           }
1506
+        }
1311 1507
     }
1312 1508
 }

+ 4 - 0
app/controller/api/store/order/StoreOrder.php

@@ -941,6 +941,10 @@ class StoreOrder extends BaseController
941 941
             $orderProduct=Db::name('store_order')->alias('so')->where('so.order_id',$order_id)->leftJoin('store_order_product sop','so.order_id=sop.order_id')->field('sop.*')->select()->toArray();
942 942
             foreach ($orderProduct as $_k=>&$_vv){
943 943
                 $_vv['cart_info']=json_decode($_vv['cart_info'],true);
944
+                $image = Db::name('store_product')->where('product_id', $_vv['cart_info']['product']['product_id'])->value('image');
945
+                if($image){
946
+                    $_vv['cart_info']['product']['image'] = $image;
947
+                }
944 948
             }
945 949
             $data['order_id']=$order_id;
946 950
             $data['orderProduct']=$orderProduct;