afa 6 months ago
parent
commit
bb883a0db4

+ 2 - 0
application/admin/view/user/userpledge/detail.html

@@ -1,6 +1,7 @@
 <table class="table table-striped">
     <thead>
         <tr>
+            <th>{:__('订单ID')}</th>
             <th>{:__('订单号')}</th>
             <th>{:__('商品')}</th>
             <th>{:__('图片')}</th>
@@ -9,6 +10,7 @@
     <tbody>
         {volist name="row" id="vo"  }
         <tr>
+            <td>{$vo.id}</td>
             <td>{$vo.order_no}</td>
             <td >{$vo.zh_name|htmlentities}</td>
             <td ><img src="{$vo.thum|htmlentities}" width="100px" height="80px"></td>

+ 1 - 1
application/api/controller/Exchange.php

@@ -194,7 +194,7 @@ class Exchange extends Api
               $ledgerWalletModel->changeWalletAccount($this->auth->id, Asset::FROZEN, $usdt_data['amount'], LedgerFrozenChangeModel::RwaExchangeRecord, 0);
 
               //发放产品奖励
-              $rs =WelfareLoginc::setUserWelfareProduct($this->auth->id, $welfare_config['product_id'], $order_no, ProductOrder::RwaExchange);
+              $rs =WelfareLoginc::setUserWelfareProduct($this->auth->id, $welfare_config['product_id'], ProductOrder::RwaExchange);
               Log::info($rs, '发放产品奖励状态');
 
               Db::commit();

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

@@ -178,7 +178,6 @@ class Order extends Api
     }
 
 
-
     //赠送
     public function giveaway(ProductOrder $productOrder, UserModel $userModel, LedgerWalletModel $ledgerWalletModel)
     {

+ 7 - 7
application/api/controller/Pledge.php

@@ -77,12 +77,12 @@ class Pledge extends Api
       public function create(ProductPledges $productPledges, PledgeLogic $pledgeLogic, LedgerWalletModel $ledgerWalletModel)
       {
         $pledge_id  = $this->request->post('pledge_id', 0, 'intval');
-        $order_no   = $this->request->post('order_no/a', '');
+        $order_id   = $this->request->post('order_id/a', '');
         $pay_type   = $this->request->post('pay_type/d', 1);//支付方式 1 茶宝 2 Teac
-        if(empty($pledge_id) || empty($order_no) || in_array($pay_type, [1,2]) == false) $this->error(__("参数有误,无可用产品"));
+        if(empty($pledge_id) || empty($order_id) || in_array($pay_type, [1,2]) == false) $this->error(__("参数有误,无可用产品"));
 
         $pledge = $productPledges::get($pledge_id);
-        $count  = count($order_no);//选择商品数量    
+        $count  = count($order_id);//选择商品数量    
         if($pledge->type_id == $productPledges::Combin && count(explode(',', $pledge->product_id)) !=  $count) $this->error(__("质押商品数量与订单数量不匹配"));
 
         //单品最大三个限制
@@ -97,7 +97,7 @@ class Pledge extends Api
         try {
 
             // 质抵押订单 
-            $res = $pledgeLogic::setPledgeOrder($pledge, $order_no, $this->auth->id, $count, $this->pay[$pay_type], $pledge[$this->pay[$pay_type]]);
+            $res = $pledgeLogic::setPledgeOrder($pledge, $order_id, $this->auth->id, $count, $this->pay[$pay_type], $pledge[$this->pay[$pay_type]]);
             // 提交事务
             Db::commit();
         } catch (Exception $e) {
@@ -205,10 +205,10 @@ class Pledge extends Api
       //添加用户存储产品
       public function addPledgeProduct(UserPledge $userPledge, PledgeLogic $pledgeLogic, ProductPledges $productPledges)
       {
-            $order_no  = $this->request->post('order_no/s', '');
+            $order_id  = $this->request->post('order_id/s', '');
             $pledge_id   = $this->request->post('pledge_id/d', 0);//存储Id
-            if(empty($order_no) || empty($pledge_id)) $this->error(__("参数有误,无可用产品"));  
-            $order_arr= explode(',', $order_no);   
+            if(empty($order_id) || empty($pledge_id)) $this->error(__("参数有误,无可用产品"));  
+            $order_arr= explode(',', $order_id);
             $count    = count($order_arr);
             $pledge = $userPledge::alias('a')->where('a.id', $pledge_id)->join('product_pledge p', 'p.id = a.pledge_id')->field('a.*,p.type_id,p.status as p_status')->find();
             if (empty($pledge) || $pledge->status != $userPledge::Ongoing ||  empty($pledge->p_status) || $pledge->type_id != $productPledges::Single) $this->error(__("产品质抵活动不存在不存在"));  

+ 8 - 9
application/api/logic/PledgeLogic.php

@@ -42,9 +42,9 @@ class PledgeLogic
     }
 
     //添加质抵押订单
-    public static function setPledgeOrder(object $pledge, array $order_no, int $user_id, int $count, string $pay_type, float $price)
+    public static function setPledgeOrder(object $pledge, array $order_id, int $user_id, int $count, string $pay_type, float $price)
     {
-        $product=  self::getOrderProductList($user_id, $order_no, $count);
+        $product=  self::getOrderProductList($user_id, $order_id, $count);
 
         if(empty($product) || count($product) < $count)  throw new Exception('订单不存在');
         $pledge_num = 1;
@@ -60,7 +60,7 @@ class PledgeLogic
         if($price >0) Loader::model('LedgerWalletModel')->changeWalletAccount($user_id, $pay_type, -$price, $action, 0);
   
         //修改状态
-        return Loader::model('ProductOrder')->whereIn('order_no', $order_no)->setField('status', ProductOrder::Freeze);
+        return Loader::model('ProductOrder')->whereIn('id', $order_id)->setField('status', ProductOrder::Freeze);
     }
 
 
@@ -117,7 +117,6 @@ class PledgeLogic
         if(count($orderId) == count($detail)) {
             $rows->status  = $model::Remove;
         }else{
-           
             $result = [];
             foreach ($detail as &$item) 
                 if(!in_array($item['id'], $orderId)) $result[] = $item;
@@ -191,13 +190,13 @@ class PledgeLogic
 
 
     //添加用户存储产品
-    public static function setPledgeProductAdd(object $pledge, int $user_id, int $count, array $order_no)
+    public static function setPledgeProductAdd(object $pledge, int $user_id, int $count, array $order_id)
     {
-        $product = self::getOrderProductList($user_id, $order_no, $count);
+        $product = self::getOrderProductList($user_id, $order_id, $count);
         if(empty($product) || count($product) < $count)  throw new Exception('订单不存在');
         
         //修改订单状态
-        Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('order_no', $order_no)->setField('status', ProductOrder::Freeze);
+        Loader::model('ProductOrder')::where('user_id', $user_id)->whereIn('id', $order_id)->setField('status', ProductOrder::Freeze);
 
         //添加产品
         $detail = json_decode($pledge->details, true);
@@ -208,12 +207,12 @@ class PledgeLogic
 
 
     //获取订单产品
-    private static function getOrderProductList(int $user_id, array $order_no, int $count)
+    private static function getOrderProductList(int $user_id, array $order_id, int $count)
     {
         return Loader::model('ProductOrder')::alias('a')
             ->join('product_list b', 'a.product_id = b.id', 'left')
             ->where('a.user_id', $user_id)
             ->where('a.status', ProductOrder::Paid)
-            ->whereIn('a.order_no', $order_no)->field('a.id,b.zh_name,b.thum,a.order_no')->limit($count)->select();
+            ->whereIn('a.id', $order_id)->field('a.id,b.zh_name,b.thum,a.order_no')->select();
     }
 }

+ 4 - 3
application/api/logic/WelfareLoginc.php

@@ -188,13 +188,14 @@ class WelfareLoginc
     }
 
     //添加Rwa兑换福利产品
-    public static function setUserWelfareProduct(int $uid, string $productId, string $orderNo, int $typeId)
+    public static function setUserWelfareProduct(int $uid, string $productId,  int $typeId)
     {
         $productOrder = Loader::model('ProductOrder');
         $productList = explode(',', $productId);
         $result = [];
-        foreach ($productList as $item) {
-            $result[] = ProductOrder::setCreateOrder(0, ['product_id'=> $item, 'area_id'=>0, 'price'=>0], $typeId, $uid, 0, $orderNo, 0, 0);
+        foreach ($productList as $k=>$item) {
+            $orderNo = getOrderSN('R'.$k);
+            $result[] = $productOrder::setCreateOrder(0, ['product_id'=> $item, 'area_id'=>0, 'price'=>0], $typeId, $uid, 0, $orderNo, 0, 0);
         }
         return $result;
     }