Explorar o código

组合支付分账问题、é—创建订单添加部分字段、修复组合支付拆分字段的脚本

hefei hai 1 ano
pai
achega
faff81cb87

+ 3 - 2
app/command/CommercialAreaOrderIndependentAccount.php

@@ -58,10 +58,11 @@ class CommercialAreaOrderIndependentAccount extends Command
58
             $group_order = Db::name('store_group_order')->alias('sgo')->where('sgo.group_order_id', $value['group_order_id'])->find();
58
             $group_order = Db::name('store_group_order')->alias('sgo')->where('sgo.group_order_id', $value['group_order_id'])->find();
59
             // @todo 分账账号 496:表示{会员专区}账户;商贸区分账如下:成本分账到商户,利润分账到{会员专区}账户
59
             // @todo 分账账号 496:表示{会员专区}账户;商贸区分账如下:成本分账到商户,利润分账到{会员专区}账户
60
             $independentAccount = $storeOrderRepository->getIndependentAccount($value, $group_order, $dst_mer_id, $merchants[$value['mer_id']]['hf_member_id']);
60
             $independentAccount = $storeOrderRepository->getIndependentAccount($value, $group_order, $dst_mer_id, $merchants[$value['mer_id']]['hf_member_id']);
61
-
61
+            $mer_price = bcsub($value['total_price'] , $value['con_pri'],2);
62
+            $platform_price = bcsub($value['fzone_pay_price'],$mer_price,2);
62
             // @todo 预分账处理
63
             // @todo 预分账处理
63
             $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
64
             $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
64
-                $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_member_id'], $independentAccount['hf_platform_member_id'], bcsub($value['total_price'] , $value['con_pri'],2), $value['con_pri']
65
+                $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_member_id'], $independentAccount['hf_platform_member_id'], $mer_price, $platform_price
65
             );
66
             );
66
             if ($isSuccessed) {
67
             if ($isSuccessed) {
67
                 Db::name("log")->insert(array('data' => '商贸区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));// 日志记录
68
                 Db::name("log")->insert(array('data' => '商贸区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));// 日志记录

+ 1 - 1
app/command/GreatLifeOrderIndependentAccount.php

@@ -63,7 +63,7 @@ class GreatLifeOrderIndependentAccount extends Command
63
 
63
 
64
             // @todo 预分账处理 496:表示{会员专区}账户,精彩生活区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
64
             // @todo 预分账处理 496:表示{会员专区}账户,精彩生活区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
65
             $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
65
             $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
66
-                $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['pay_price'], 0
66
+                $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['fzone_pay_price'], 0
67
             );
67
             );
68
             if ($isSuccessed) {
68
             if ($isSuccessed) {
69
                 Db::name("log")->insert(array('data' => '精彩生活区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));// 日志记录
69
                 Db::name("log")->insert(array('data' => '精彩生活区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));// 日志记录

+ 72 - 0
app/command/repairFzonePayType.php

@@ -0,0 +1,72 @@
1
+<?php
2
+declare (strict_types=1);
3
+
4
+namespace app\command;
5
+
6
+use think\console\Command;
7
+use think\console\Input;
8
+use think\console\Output;
9
+use think\facade\Db;
10
+
11
+class repairFzonePayType extends Command
12
+{
13
+    protected function configure()
14
+    {
15
+        // 指令配置
16
+        $this->setName('repair_fzone_pay_type')
17
+            ->setDescription('修复组合支付json数据赋值到对应字段');
18
+    }
19
+
20
+    /**
21
+     * @param Input $input
22
+     * @param Output $output
23
+     * @return void
24
+     */
25
+    protected function execute(Input $input, Output $output)
26
+    {
27
+        $order_list = Db::name('store_order')->field('order_id,fzone_paytype')->order('order_id asc')->select()->toArray();
28
+        foreach ($order_list as $value){
29
+            if(!$value['fzone_paytype']) continue;
30
+            $array_fzone_paytype = json_decode($value['fzone_paytype'],true);
31
+            if(!empty($array_fzone_paytype['type'])){
32
+                $array_fzone_paytype_all = [
33
+                    'fzone_pay_jingdou' => 0,
34
+                    'fzone_pay_vr' => 0,
35
+                    'fzone_pay_jifen' => 0,
36
+                    'fzone_pay_price' => 0,
37
+                    'fzone_pay_other' => $array_fzone_paytype['other'],
38
+                    'fzone_pay_note' => $array_fzone_paytype['note'],
39
+                    'fzone_pay_type' => $array_fzone_paytype['type'],
40
+                ];
41
+                if(!empty($array_fzone_paytype['type'] == 'b1')){
42
+                    $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
43
+                    $array_fzone_paytype_all['fzone_pay_jifen'] = $array_fzone_paytype['other'];
44
+                }else if(!empty($array_fzone_paytype['type'] == 'b2')){
45
+                    $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
46
+                    $array_fzone_paytype_all['fzone_pay_jifen'] = $array_fzone_paytype['other'];
47
+                }else if(!empty($array_fzone_paytype['type'] == 'b3')){
48
+                    $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
49
+                    $array_fzone_paytype_all['fzone_pay_jingdou'] = $array_fzone_paytype['other'];
50
+                }else if(!empty($array_fzone_paytype['type'] == 'b4')){
51
+                    $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
52
+                    $array_fzone_paytype_all['fzone_pay_jingdou'] = $array_fzone_paytype['other'];
53
+                }else if(!empty($array_fzone_paytype['type'] == 'b5')){
54
+                    $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
55
+                }else if(!empty($array_fzone_paytype['type'] == 'a1')){
56
+                    $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
57
+                }else if(!empty($array_fzone_paytype['type'] == 'a3')){
58
+                    $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
59
+                    $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['other'];
60
+                }else if(!empty($array_fzone_paytype['type'] == 'c1')){
61
+                    $array_fzone_paytype_all['fzone_pay_other'] = $array_fzone_paytype['price'];
62
+                }else{
63
+                    $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
64
+                }
65
+                Db::name('store_order')->where('order_id',$value['order_id'])->update($array_fzone_paytype_all);
66
+                $output->writeln("订单ID:". $value['order_id'] ."修复成功");
67
+            }
68
+        }
69
+        $output->writeln('执行结束');
70
+    }
71
+
72
+}

+ 9 - 2
app/common/repositories/store/order/StoreOrderRepository.php

@@ -122,7 +122,7 @@ class StoreOrderRepository extends BaseRepository
122
      * @author xaboy
122
      * @author xaboy
123
      * @day 2020/8/1
123
      * @day 2020/8/1
124
      */
124
      */
125
-    public function createOrder(User $user, int $pay_type, $cartId, $addressId, $coupons, $takes, $mark, $psType, $table_id = null, $share_id = 0, $payType, $mer_id = 0, $dacang_id = 0, $distribution_mode = 1, $ziti_address = '', $area_manage_address_ids = '', $youhui_price_key = '', $cartIdAndPayTypMap, $fzone_paytype = '', $getuserofgoodsid = '')
125
+    public function createOrder(User $user, int $pay_type, $cartId, $addressId, $coupons, $takes, $mark, $psType, $table_id = null, $share_id = 0, $payType, $mer_id = 0, $dacang_id = 0, $distribution_mode = 1, $ziti_address = '', $area_manage_address_ids = '', $youhui_price_key = '', $cartIdAndPayTypMap, $fzone_paytype = '', $getuserofgoodsid = '',$array_fzone_paytype_all = array())
126
     {
126
     {
127
 
127
 
128
 
128
 
@@ -783,6 +783,13 @@ class StoreOrderRepository extends BaseRepository
783
                     'fzone_paytype' => $fzone_paytype,
783
                     'fzone_paytype' => $fzone_paytype,
784
                     'con_pri' => $product_attr_unique_datas['plate_mer_profit'],//计算商品选中的产品规格,然后计算利润,这个利润会在每周分红中进行分润
784
                     'con_pri' => $product_attr_unique_datas['plate_mer_profit'],//计算商品选中的产品规格,然后计算利润,这个利润会在每周分红中进行分润
785
                     'user_of_goods_id' => $getuserofgoodsid,
785
                     'user_of_goods_id' => $getuserofgoodsid,
786
+                    'fzone_pay_jingdou' => $array_fzone_paytype_all['fzone_pay_jingdou'],
787
+                    'fzone_pay_vr' => $array_fzone_paytype_all['fzone_pay_vr'],
788
+                    'fzone_pay_jifen' => $array_fzone_paytype_all['fzone_pay_jifen'],
789
+                    'fzone_pay_price' => $array_fzone_paytype_all['fzone_pay_price'],
790
+                    'fzone_pay_other' => $array_fzone_paytype_all['fzone_pay_other'],
791
+                    'fzone_pay_note' => $array_fzone_paytype_all['fzone_pay_note'],
792
+                    'fzone_pay_type' => $array_fzone_paytype_all['fzone_pay_type'],
786
                 ];
793
                 ];
787
 
794
 
788
 
795
 
@@ -10532,7 +10539,7 @@ class StoreOrderRepository extends BaseRepository
10532
             // @todo 预分账处理 496:表示{会员专区}账户,本区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
10539
             // @todo 预分账处理 496:表示{会员专区}账户,本区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
10533
             $isSuccessed = $this->prepareExecuteIndependentAccount(
10540
             $isSuccessed = $this->prepareExecuteIndependentAccount(
10534
                 $order, $order_group_data, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '',
10541
                 $order, $order_group_data, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '',
10535
-                $order['pay_price'], 0
10542
+                $order['fzone_pay_price'], 0
10536
             );
10543
             );
10537
             if ($isSuccessed) {
10544
             if ($isSuccessed) {
10538
                 Db::name("store_order")->where('order_sn', $order['order_sn'])->update(['is_independentaccount' => 1]);
10545
                 Db::name("store_order")->where('order_sn', $order['order_sn'])->update(['is_independentaccount' => 1]);

+ 26 - 9
app/controller/api/store/order/StoreOrder.php

@@ -456,7 +456,15 @@ class StoreOrder extends BaseController
456
         //判断组合支付逻辑,积分、VR、京豆
456
         //判断组合支付逻辑,积分、VR、京豆
457
         $userdatas =Db::name("user")->where("uid",$uid)->find();
457
         $userdatas =Db::name("user")->where("uid",$uid)->find();
458
         $array_fzone_paytype = json_decode($fzone_paytype,true);
458
         $array_fzone_paytype = json_decode($fzone_paytype,true);
459
-
459
+        $array_fzone_paytype_all = [
460
+            'fzone_pay_jingdou' => 0,
461
+            'fzone_pay_vr' => 0,
462
+            'fzone_pay_jifen' => 0,
463
+            'fzone_pay_price' => 0,
464
+            'fzone_pay_other' => $array_fzone_paytype['other'],
465
+            'fzone_pay_note' => $array_fzone_paytype['note'],
466
+            'fzone_pay_type' => $array_fzone_paytype['type'],
467
+        ];
460
 
468
 
461
         //会员专区升级产生的user_of_goods订单ID赋值
469
         //会员专区升级产生的user_of_goods订单ID赋值
462
         $getuserofgoodsid = 1;
470
         $getuserofgoodsid = 1;
@@ -471,7 +479,8 @@ class StoreOrder extends BaseController
471
                 if($vrpri < 0 || $pricepri < 0){
479
                 if($vrpri < 0 || $pricepri < 0){
472
                     return app('json')->fail("支付失败,VR或积分不足!");
480
                     return app('json')->fail("支付失败,VR或积分不足!");
473
                 }
481
                 }
474
-
482
+                $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
483
+                $array_fzone_paytype_all['fzone_pay_jifen'] = $array_fzone_paytype['other'];
475
 
484
 
476
             }else if(!empty($array_fzone_paytype['type'] == 'b2')){
485
             }else if(!empty($array_fzone_paytype['type'] == 'b2')){
477
                 //精彩生活现金+积分
486
                 //精彩生活现金+积分
@@ -483,7 +492,8 @@ class StoreOrder extends BaseController
483
                 if($vrpri  < 0 ){
492
                 if($vrpri  < 0 ){
484
                     return app('json')->fail("支付失败,积分不足!");
493
                     return app('json')->fail("支付失败,积分不足!");
485
                 }
494
                 }
486
-
495
+                $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
496
+                $array_fzone_paytype_all['fzone_pay_jifen'] = $array_fzone_paytype['other'];
487
 
497
 
488
             }else if(!empty($array_fzone_paytype['type'] == 'b3')){
498
             }else if(!empty($array_fzone_paytype['type'] == 'b3')){
489
                 //精彩生活区 VR+京豆
499
                 //精彩生活区 VR+京豆
@@ -493,16 +503,18 @@ class StoreOrder extends BaseController
493
                 if($vrpri < 0 || $pricepri < 0){
503
                 if($vrpri < 0 || $pricepri < 0){
494
                     return app('json')->fail("支付失败,VR或京豆不足!");
504
                     return app('json')->fail("支付失败,VR或京豆不足!");
495
                 }
505
                 }
496
-
506
+                $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
507
+                $array_fzone_paytype_all['fzone_pay_jingdou'] = $array_fzone_paytype['other'];
497
             }else if(!empty($array_fzone_paytype['type'] == 'b4')){
508
             }else if(!empty($array_fzone_paytype['type'] == 'b4')){
498
-                //精彩生活区 VR+京豆
509
+                //精彩生活区 现金+京豆
499
                 $pricepri = $userdatas['jingdou'] -  $array_fzone_paytype['other'];
510
                 $pricepri = $userdatas['jingdou'] -  $array_fzone_paytype['other'];
500
 
511
 
501
                 // //现金+积分
512
                 // //现金+积分
502
                 if($pricepri  < 0 ){
513
                 if($pricepri  < 0 ){
503
                     return app('json')->fail("支付失败,京豆不足!");
514
                     return app('json')->fail("支付失败,京豆不足!");
504
                 }
515
                 }
505
-
516
+                $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
517
+                $array_fzone_paytype_all['fzone_pay_jingdou'] = $array_fzone_paytype['other'];
506
 //                return app('json')->fail("开发中升级中!");
518
 //                return app('json')->fail("开发中升级中!");
507
 
519
 
508
             }else if(!empty($array_fzone_paytype['type'] == 'b5')){
520
             }else if(!empty($array_fzone_paytype['type'] == 'b5')){
@@ -513,6 +525,7 @@ class StoreOrder extends BaseController
513
                 if($vrpri < 0){
525
                 if($vrpri < 0){
514
                     return app('json')->fail("支付失败,VR不足!");
526
                     return app('json')->fail("支付失败,VR不足!");
515
                 }
527
                 }
528
+                $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
516
             }else if(!empty($array_fzone_paytype['type'] == 'a1')){
529
             }else if(!empty($array_fzone_paytype['type'] == 'a1')){
517
                 //生活 VR支付
530
                 //生活 VR支付
518
 
531
 
@@ -522,6 +535,7 @@ class StoreOrder extends BaseController
522
                 if($vrpri < 0){
535
                 if($vrpri < 0){
523
                     return app('json')->fail("支付失败,VR不足!");
536
                     return app('json')->fail("支付失败,VR不足!");
524
                 }
537
                 }
538
+                $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['price'];
525
                // return app('json')->fail($userdatas['spread_old']);
539
                // return app('json')->fail($userdatas['spread_old']);
526
                 //检查在旧表中是否有上级
540
                 //检查在旧表中是否有上级
527
                 if($userdatas['spread_old'] != 0){
541
                 if($userdatas['spread_old'] != 0){
@@ -614,8 +628,8 @@ class StoreOrder extends BaseController
614
 
628
 
615
 
629
 
616
                 }
630
                 }
617
-
618
-               
631
+                $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
632
+                $array_fzone_paytype_all['fzone_pay_vr'] = $array_fzone_paytype['other'];
619
 
633
 
620
             }else if(!empty($array_fzone_paytype['type'] == 'c1')){
634
             }else if(!empty($array_fzone_paytype['type'] == 'c1')){
621
                 //复购区 复购金支付
635
                 //复购区 复购金支付
@@ -624,6 +638,9 @@ class StoreOrder extends BaseController
624
                 if($fugoupri < 0){
638
                 if($fugoupri < 0){
625
                     return app('json')->fail("支付失败,复购金不足!");
639
                     return app('json')->fail("支付失败,复购金不足!");
626
                 }
640
                 }
641
+                $array_fzone_paytype_all['fzone_pay_other'] = $array_fzone_paytype['price'];
642
+            }else{
643
+                $array_fzone_paytype_all['fzone_pay_price'] = $array_fzone_paytype['price'];
627
             }
644
             }
628
         }
645
         }
629
 
646
 
@@ -633,7 +650,7 @@ class StoreOrder extends BaseController
633
 
650
 
634
         makeLock()->lock();
651
         makeLock()->lock();
635
         try {
652
         try {
636
-            $groupOrder = $this->repository->createOrder($this->request->userInfo(), $payType, [$cartId], $addressId, 0,0, 0,0,0,0,0,$mer_id,0,0,0,0,0,0,$fzone_paytype,$getuserofgoodsid);
653
+            $groupOrder = $this->repository->createOrder($this->request->userInfo(), $payType, [$cartId], $addressId, 0,0, 0,0,0,0,0,$mer_id,0,0,0,0,0,0,$fzone_paytype,$getuserofgoodsid,$array_fzone_paytype_all);
637
             //var_dump($groupOrder);
654
             //var_dump($groupOrder);
638
         } catch (\Throwable $e) {
655
         } catch (\Throwable $e) {
639
             makeLock()->unlock();
656
             makeLock()->unlock();

+ 1 - 0
config/console.php

@@ -31,5 +31,6 @@ return [
31
         'gzcAddByBill' => 'app\command\GzcAddByBillCommand',
31
         'gzcAddByBill' => 'app\command\GzcAddByBillCommand',
32
         'movie_order' => 'app\command\MovieOrderCommand',
32
         'movie_order' => 'app\command\MovieOrderCommand',
33
         'repair_pay_success' => 'app\command\repairPaySuccess',
33
         'repair_pay_success' => 'app\command\repairPaySuccess',
34
+        'repair_fzone_pay_type' => 'app\command\repairFzonePayType',
34
     ],
35
     ],
35
 ];
36
 ];