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