xialei hai 1 ano
pai
achega
ec4ce54f9e

+ 41 - 0
app/common/repositories/user/UserThirdRepository.php

@@ -658,6 +658,47 @@ class UserThirdRepository extends BaseRepository
658 658
         Db::name('log')->insert(['data' => "type_shop:{$type_shop}, $order_sn, $order_sn, 修改积分,养老金,贡献值,红包记录, 更新成功!!!"]);
659 659
     }
660 660
 
661
+
662
+    //添加预估复购金记录
663
+    public static function yuguFugou($price,$user_id,$order_sn,$type_shop){
664
+        try {
665
+            $inc_score = $price * 0.1;//推广者的佣金抽10%到个人复购金
666
+
667
+            $make="";
668
+            if($type_shop==1){
669
+                $make="拼多多";
670
+            }else if($type_shop==5){
671
+                $make="淘宝";
672
+            }else if($type_shop==6){
673
+                $make="京东";
674
+            }else if($type_shop==3){
675
+                $make="苏宁";
676
+            }else if($type_shop==2){
677
+                $make="唯品会";
678
+            }else if($type_shop==9){
679
+                $make="话费";
680
+            }
681
+
682
+            $bill = [
683
+                'uid'=>$user_id,
684
+                'number'=>$inc_score,//数量
685
+                'status'=>-1,//复购金状态1-有效 0-失效 -1待确认
686
+                'mark'=>"购买{$make}商品赠送积分",//备注
687
+                'order_id'=>$order_sn,//订单id
688
+                'surplus'=>0,//剩余
689
+                'order_type'=>11,//关联订单ID
690
+                'type'=>1,//复购金类型 :1赠送,2消耗
691
+                'settlement_time'=>date('Y-m-d H:i:s'),//添加时间,
692
+                'addtime'=>time(),
693
+            ];
694
+
695
+            Db::name('user_sign_fugou')->insert($bill);
696
+        }  catch (Exception $e) {
697
+            return app("json")->fail($e->getMessage());
698
+        }
699
+    }
700
+
701
+
661 702
     /**
662 703
      * 添加预估积分记录
663 704
      */

+ 27 - 18
app/controller/api/store/service/Huafei.php

@@ -42,24 +42,33 @@ class Huafei extends BaseController
42 42
 		];
43 43
 		$ret = Db::name("order_huafei")->where("order_number", $order_number)->where("order_sn", $order_no)->update($updateData);
44 44
 		if($ret){
45
-			//判断数据库有无此订单
46
-			$type_shop = 9;
47
-			$orderThird = app()->make(UserThirdRepository::class);
48
-			//预估养老金
49
-			$orderThird->yuguOrder(
50
-				$huafeiInfo['order_pdd_id'],
51
-				$huafeiInfo['commission'],
52
-				$huafeiInfo['uid'],
53
-				$huafeiInfo['order_sn'],
54
-				$type_shop,
55
-				'order_huafei');
56
-			//预估积分
57
-			$orderThird->yuguJifen(
58
-				$huafeiInfo['commission'] ,
59
-				$huafeiInfo['uid'],
60
-				$huafeiInfo['order_sn'],
61
-				$type_shop
62
-			);
45
+			if($param['status'] == 2) {
46
+				//判断数据库有无此订单
47
+				$type_shop = 9;
48
+				$orderThird = app()->make(UserThirdRepository::class);
49
+				//预估养老金
50
+				$orderThird->yuguOrder(
51
+					$huafeiInfo['order_pdd_id'],
52
+					$huafeiInfo['commission'],
53
+					$huafeiInfo['uid'],
54
+					$huafeiInfo['order_sn'],
55
+					$type_shop,
56
+					'order_huafei');
57
+				//预估积分
58
+				$orderThird->yuguJifen(
59
+					$huafeiInfo['commission'] ,
60
+					$huafeiInfo['uid'],
61
+					$huafeiInfo['order_sn'],
62
+					$type_shop
63
+				);	
64
+				//复购金
65
+				$orderThird->yuguFugou(
66
+					$huafeiInfo['commission'] ,
67
+					$huafeiInfo['uid'],
68
+					$huafeiInfo['order_sn'],
69
+					$type_shop
70
+				);	
71
+			}
63 72
 
64 73
 			echo 'success';exit;
65 74
 		}else{