Browse Source

钱包迁移,api,陪玩单

lizhen_gitee 2 years ago
parent
commit
231ab5c64d

+ 29 - 22
application/api/controller/Dispatch.php

@@ -632,10 +632,17 @@ class Dispatch extends Common
                     $this->error(__('账户资金异常,请联系管理员!'),[],105);
                 }
                 $res1 = $userModel->where($where)->setDec("frozen",$money);//下单用户
-                $res2 = $userModel->where($where)->setInc("jewel",$money);//下单用户
+                $res2 = true;//下单用户
                 // 添加用户余额变动记录
-                $userjewellogModel = new \app\common\model\UserJewelLog();
-                $res3 = $userjewellogModel->addUserJewelLog($orderInfo["user_id"], $money, "+", $userInfo["jewel"], "拒绝订单返还余额", 7);
+                $res3 = true;
+
+                //增加用户钻石余额
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($orderInfo["user_id"], $money, "+", 0, "拒绝订单返还余额", 7,'jewel');
+                if($rs_wallet['status'] == false){
+                    Db::rollback();
+                    $this->error($rs_wallet['msg']);
+                }
+
                 // 更新订单状态
                 $data = [];
                 $data["status"] = $status;
@@ -675,27 +682,21 @@ class Dispatch extends Common
                 $userModel = new \app\common\model\User();
                 $money = $orderInfo["price"] * $orderInfo["num"];
                 // 增加用户余额
+                $res1 = true;
+                //
                 $where = [];
-                $where["id"] = $orderInfo["recive_id"];
-                $userInfo = $userModel->where($where)->find();
-                //$res1 = $userModel->where($where)->setInc("jewel",$money);
-                $jewelMoneyRate = config('site.money_to_jewel');//1人民币兑换钻石数
-                $moneyRmb = bcdiv($money,$jewelMoneyRate);
-                $res1 = $userModel->where($where)->setInc("money",$moneyRmb);
-                $where = [];
-                $where["id"] = $this->auth->id;
+                $where["id"] = $orderInfo['user_id'];
                 $res2 = $userModel->where($where)->setDec("frozen",$money);
                 // 添加用户余额变动记录
-                /*$userjewellogModel = new \app\common\model\UserJewelLog();
-                $res3 = $userjewellogModel->addUserJewelLog($orderInfo["recive_id"], $money, "+", $userInfo["jewel"], "完成用户订单获得收益", 8);*/
+                $res3 = true;
+
                 $remark = $orderInfo['skill_name'].'服务';
-                $rs_wallet = model('wallet')->lockChangeAccountRemain($orderInfo["recive_id"],$moneyRmb,'+',$userInfo['money'],$remark,106,'money');
-                $res3 = false;
+                $jewelMoneyRate = config('site.money_to_jewel');//1人民币兑换钻石数
+                $moneyRmb = bcdiv($money,$jewelMoneyRate);
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($orderInfo["recive_id"],$moneyRmb,'+',0,$remark,106,'money');
                 if($rs_wallet['status'] == false){
-                    $this->error($rs_wallet['msg']);
                     Db::rollback();
-                } else {
-                    $res3 = true;
+                    $this->error($rs_wallet['msg']);
                 }
                 // 更新订单状态
                 $data = [];
@@ -739,16 +740,22 @@ class Dispatch extends Common
                 $money = $orderInfo["price"] * $orderInfo["num"];
                 // 解冻用户余额
                 $where = [];
-                $where["id"] = $this->auth->id;
+                $where["id"] = $orderInfo['user_id'];
                 $userInfo = $userModel->where($where)->find();
                 if($userInfo["frozen"] - $money < 0) {
                     $this->error(__('账户资金异常,请联系管理员!'),[],105);
                 }
                 $res1 = $userModel->where($where)->setDec("frozen",$money);
-                $res2 = $userModel->where($where)->setInc("jewel",$money);
+                $res2 = true;
                 // 添加用户余额变动记录
-                $userjewellogModel = new \app\common\model\UserJewelLog();
-                $res3 = $userjewellogModel->addUserJewelLog($orderInfo["user_id"], $money, "+", $userInfo["jewel"], "取消订单返还余额", 7);
+                $res3 = true;
+
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($orderInfo["user_id"], $money, "+", 0, "取消订单返还余额", 7,'money');
+                if($rs_wallet['status'] == false){
+                    Db::rollback();
+                    $this->error($rs_wallet['msg']);
+                }
+
                 // 更新订单状态
                 $data = [];
                 $data["status"] = $status;

+ 1 - 0
application/api/controller/Live.php

@@ -607,6 +607,7 @@ class Live extends Common
      * 赠送礼物
      */
     public function giveGiftToYou() {
+        exit;
         $user_id = $this->request->request("user_id");// 赠送对象
         $gift_id = $this->request->request("gift_id");// 礼物ID
         $live_id = $this->request->request("live_id");// 直播间ID

+ 1 - 0
application/api/controller/Money.php

@@ -804,6 +804,7 @@ class Money extends Common
      */
     public function exchangeSoundcoin()
     {
+        exit;
         // 接口防并发
         if (!$this->apiLimit(1, 1000)) {
             $this->error(__('Operation frequently'));

+ 1 - 1
application/extra/wallet.php

@@ -14,7 +14,7 @@ return [
         15 => '开通贵族赠送', //增加
         6  => '购买装扮',    //减少
         7  => '拒绝订单返还',    //增加
-        8  => '完成用户订单获得收益',    //增加                          需要测试
+        8  => '完成用户订单获得收益',    //增加  用不到了,改成106了
         9  => '获赠礼物', //增加     api/Live.php大概率废弃了
         11 => '私聊转账',  //减少
         12 => '私聊到账',  //增加