正在显示
5 个修改的文件
包含
64 行增加
和
3 行删除
@@ -97,9 +97,15 @@ class Car extends Frontend | @@ -97,9 +97,15 @@ class Car extends Frontend | ||
97 | if(empty($car)){ | 97 | if(empty($car)){ |
98 | //新增 | 98 | //新增 |
99 | //判断库存是否充足 | 99 | //判断库存是否充足 |
100 | - if($data['inventory'] < 1){ | 100 | + if($data['inventory'] < $car['number']+$number){ |
101 | $this->error("商品 【$data[goodsname]】 库存不足~"); | 101 | $this->error("商品 【$data[goodsname]】 库存不足~"); |
102 | } | 102 | } |
103 | + //是否超出商品限购数量 | ||
104 | + if($data['is_impose'] == '1'){ | ||
105 | + if($data['imposenum'] < $car['number']+$number){ | ||
106 | + $this->error("商品 【$data[goodsname]】 超出限购数量~"); | ||
107 | + } | ||
108 | + } | ||
103 | $arr['createtime'] = time(); | 109 | $arr['createtime'] = time(); |
104 | $result = $carModel->insertData($arr); | 110 | $result = $carModel->insertData($arr); |
105 | }else{ | 111 | }else{ |
@@ -108,9 +114,15 @@ class Car extends Frontend | @@ -108,9 +114,15 @@ class Car extends Frontend | ||
108 | if($type == 1){ | 114 | if($type == 1){ |
109 | //增加数量 | 115 | //增加数量 |
110 | //判断库存是否充足 | 116 | //判断库存是否充足 |
111 | - if($data['inventory'] < 1){ | 117 | + if($data['inventory'] < $car['number']+$number){ |
112 | $this->error("商品 【$data[goodsname]】 库存不足~"); | 118 | $this->error("商品 【$data[goodsname]】 库存不足~"); |
113 | } | 119 | } |
120 | + //是否超出商品限购数量 | ||
121 | + if($data['is_impose'] == '1'){ | ||
122 | + if($data['imposenum'] < $car['number']+$number){ | ||
123 | + $this->error("商品 【$data[goodsname]】 超出限购数量~"); | ||
124 | + } | ||
125 | + } | ||
114 | $result = $carModel->where(['id'=>$car['id']])->setInc('number',$number); | 126 | $result = $carModel->where(['id'=>$car['id']])->setInc('number',$number); |
115 | }else{ | 127 | }else{ |
116 | //减少数量 | 128 | //减少数量 |
@@ -97,6 +97,9 @@ class Member extends Frontend | @@ -97,6 +97,9 @@ class Member extends Frontend | ||
97 | ]; | 97 | ]; |
98 | if($param['status']) { | 98 | if($param['status']) { |
99 | $where['status'] = $param['status']; | 99 | $where['status'] = $param['status']; |
100 | + if($param['status']==5){ | ||
101 | + $where['status'] = ['in',['5','6','8','11']]; | ||
102 | + } | ||
100 | } | 103 | } |
101 | $order = $order_detail_model | 104 | $order = $order_detail_model |
102 | ->where($where) | 105 | ->where($where) |
@@ -387,7 +390,7 @@ class Member extends Frontend | @@ -387,7 +390,7 @@ class Member extends Frontend | ||
387 | '10' => '已删除', | 390 | '10' => '已删除', |
388 | ]; | 391 | ]; |
389 | $order['store_name'] = $store_model->where('id',$order['store_id'])->value('name'); | 392 | $order['store_name'] = $store_model->where('id',$order['store_id'])->value('name'); |
390 | - $order['goods'] = $order_info_model->where('order_id',$order['id'])->select(); | 393 | + $order['goods'] = $order_info_model->where('order_detail_id',$order['id'])->select(); |
391 | $order['status'] = $status[$order['status']]; | 394 | $order['status'] = $status[$order['status']]; |
392 | $this->view->assign('order',$order); | 395 | $this->view->assign('order',$order); |
393 | return $this->view->fetch(); | 396 | return $this->view->fetch(); |
@@ -11,6 +11,7 @@ namespace app\index\controller; | @@ -11,6 +11,7 @@ namespace app\index\controller; | ||
11 | use app\common\controller\Api; | 11 | use app\common\controller\Api; |
12 | use app\common\controller\Frontend; | 12 | use app\common\controller\Frontend; |
13 | use app\index\model\OrderDetail; | 13 | use app\index\model\OrderDetail; |
14 | +use app\index\model\OrderInfo; | ||
14 | use app\index\model\Store; | 15 | use app\index\model\Store; |
15 | use app\index\model\Viporder; | 16 | use app\index\model\Viporder; |
16 | use think\Db; | 17 | use think\Db; |
@@ -94,6 +95,7 @@ class Notify extends Frontend | @@ -94,6 +95,7 @@ class Notify extends Frontend | ||
94 | $identification = substr($out_trade_no, -1); | 95 | $identification = substr($out_trade_no, -1); |
95 | $orderModel = new \app\index\model\Order(); | 96 | $orderModel = new \app\index\model\Order(); |
96 | $orderDetailModel = new OrderDetail(); | 97 | $orderDetailModel = new OrderDetail(); |
98 | + $orderInfoModel = new OrderInfo(); | ||
97 | if($identification == 1){ | 99 | if($identification == 1){ |
98 | $data = $orderModel->findData(['num'=>$out_trade_no]); | 100 | $data = $orderModel->findData(['num'=>$out_trade_no]); |
99 | }else{ | 101 | }else{ |
@@ -113,12 +115,21 @@ class Notify extends Frontend | @@ -113,12 +115,21 @@ class Notify extends Frontend | ||
113 | if($identification == 1){ | 115 | if($identification == 1){ |
114 | $orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 116 | $orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
115 | $orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 117 | $orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
118 | + $order_info = $orderInfoModel->selectData(['order_id'=>$data['id']]); | ||
116 | }else{ | 119 | }else{ |
117 | $orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 120 | $orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
118 | $order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']); | 121 | $order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']); |
119 | if($order_detail_status1_count == 0){ | 122 | if($order_detail_status1_count == 0){ |
120 | $orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']); | 123 | $orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']); |
121 | } | 124 | } |
125 | + $order_info = $orderInfoModel->selectData(['order_detail_id'=>$data['id']]); | ||
126 | + } | ||
127 | + $goodsModel = new \app\index\model\Goods(); | ||
128 | + //扣除库存、增销量 | ||
129 | + foreach($order_info as $key => $o_i){ | ||
130 | +// $goods = $goodsModel->findData(['g.id'=>$o_i['goods_id']]); | ||
131 | + $goodsModel->where(['id'=>$o_i['goods_id']])->setDec('inventory',$o_i['number']); | ||
132 | + $goodsModel->where(['id'=>$o_i['goods_id']])->setInc('sale',$o_i['number']); | ||
122 | } | 133 | } |
123 | } | 134 | } |
124 | return true; // 返回处理完成 | 135 | return true; // 返回处理完成 |
@@ -96,6 +96,12 @@ class Order extends Frontend | @@ -96,6 +96,12 @@ class Order extends Frontend | ||
96 | if($goods['inventory'] < $number[$key4]){ | 96 | if($goods['inventory'] < $number[$key4]){ |
97 | $this->error("商品 【$goods[goodsname]】 库存不足~"); | 97 | $this->error("商品 【$goods[goodsname]】 库存不足~"); |
98 | } | 98 | } |
99 | + //是否超出商品限购数量 | ||
100 | + if($goods['is_impose'] == '1'){ | ||
101 | + if($goods['imposenum'] < $number[$key4]){ | ||
102 | + $this->error("商品 【$goods[goodsname]】 超出限购数量~"); | ||
103 | + } | ||
104 | + } | ||
99 | $goods['number'] = $number[$key4]; | 105 | $goods['number'] = $number[$key4]; |
100 | $goods_price[] = $goods['price']*$number[$key4]; | 106 | $goods_price[] = $goods['price']*$number[$key4]; |
101 | $goods_arr[] = $goods; | 107 | $goods_arr[] = $goods; |
@@ -215,6 +221,12 @@ class Order extends Frontend | @@ -215,6 +221,12 @@ class Order extends Frontend | ||
215 | if($goods['inventory'] < $number[$key4]){ | 221 | if($goods['inventory'] < $number[$key4]){ |
216 | $this->error("商品 【$goods[goodsname]】 库存不足~"); | 222 | $this->error("商品 【$goods[goodsname]】 库存不足~"); |
217 | } | 223 | } |
224 | + //是否超出商品限购数量 | ||
225 | + if($goods['is_impose'] == '1'){ | ||
226 | + if($goods['imposenum'] < $number[$key4]){ | ||
227 | + $this->error("商品 【$goods[goodsname]】 超出限购数量~"); | ||
228 | + } | ||
229 | + } | ||
218 | $goods['number'] = $number[$key4]; | 230 | $goods['number'] = $number[$key4]; |
219 | $goods_price[] = $goods['price']*$number[$key4]; | 231 | $goods_price[] = $goods['price']*$number[$key4]; |
220 | $goods_arr[] = $goods; | 232 | $goods_arr[] = $goods; |
@@ -322,6 +334,12 @@ class Order extends Frontend | @@ -322,6 +334,12 @@ class Order extends Frontend | ||
322 | if($goods['inventory'] < $number[$key4]){ | 334 | if($goods['inventory'] < $number[$key4]){ |
323 | $this->error("商品 【$goods[goodsname]】 库存不足~"); | 335 | $this->error("商品 【$goods[goodsname]】 库存不足~"); |
324 | } | 336 | } |
337 | + //是否超出商品限购数量 | ||
338 | + if($goods['is_impose'] == '1'){ | ||
339 | + if($goods['imposenum'] < $number[$key4]){ | ||
340 | + $this->error("商品 【$goods[goodsname]】 超出限购数量~"); | ||
341 | + } | ||
342 | + } | ||
325 | $goods['number'] = $number[$key4]; | 343 | $goods['number'] = $number[$key4]; |
326 | $goods_price[] = $goods['price']*$number[$key4]; | 344 | $goods_price[] = $goods['price']*$number[$key4]; |
327 | $goods_arr[] = $goods; | 345 | $goods_arr[] = $goods; |
@@ -453,6 +471,12 @@ class Order extends Frontend | @@ -453,6 +471,12 @@ class Order extends Frontend | ||
453 | if($goods['inventory'] < $o_i['number']){ | 471 | if($goods['inventory'] < $o_i['number']){ |
454 | $this->error("商品 【$goods[goodsname]】 库存不足~"); | 472 | $this->error("商品 【$goods[goodsname]】 库存不足~"); |
455 | } | 473 | } |
474 | + //是否超出商品限购数量 | ||
475 | + if($goods['is_impose'] == '1'){ | ||
476 | + if($goods['imposenum'] < $o_i['number']){ | ||
477 | + $this->error("商品 【$goods[goodsname]】 超出限购数量~"); | ||
478 | + } | ||
479 | + } | ||
456 | } | 480 | } |
457 | if($data['pay_type'] == '1'){ | 481 | if($data['pay_type'] == '1'){ |
458 | //微信支付 | 482 | //微信支付 |
@@ -4,6 +4,7 @@ namespace app\index\controller; | @@ -4,6 +4,7 @@ namespace app\index\controller; | ||
4 | 4 | ||
5 | use app\common\controller\HomeBase; | 5 | use app\common\controller\HomeBase; |
6 | use app\index\model\OrderDetail; | 6 | use app\index\model\OrderDetail; |
7 | +use app\index\model\OrderInfo; | ||
7 | use app\index\model\Store; | 8 | use app\index\model\Store; |
8 | use app\index\model\Viporder; | 9 | use app\index\model\Viporder; |
9 | use EasyWeChat\Foundation\Application; | 10 | use EasyWeChat\Foundation\Application; |
@@ -162,6 +163,7 @@ class WechatPay extends HomeBase | @@ -162,6 +163,7 @@ class WechatPay extends HomeBase | ||
162 | $identification = substr($out_trade_no, -1); | 163 | $identification = substr($out_trade_no, -1); |
163 | $orderModel = new \app\index\model\Order(); | 164 | $orderModel = new \app\index\model\Order(); |
164 | $orderDetailModel = new OrderDetail(); | 165 | $orderDetailModel = new OrderDetail(); |
166 | + $orderInfoModel = new OrderInfo(); | ||
165 | if($identification == 1){ | 167 | if($identification == 1){ |
166 | $data = $orderModel->findData(['num'=>$out_trade_no]); | 168 | $data = $orderModel->findData(['num'=>$out_trade_no]); |
167 | }else{ | 169 | }else{ |
@@ -180,12 +182,21 @@ class WechatPay extends HomeBase | @@ -180,12 +182,21 @@ class WechatPay extends HomeBase | ||
180 | if($identification == 1){ | 182 | if($identification == 1){ |
181 | $orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 183 | $orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
182 | $orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 184 | $orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
185 | + $order_info = $orderInfoModel->selectData(['order_id'=>$data['id']]); | ||
183 | }else{ | 186 | }else{ |
184 | $orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); | 187 | $orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']); |
185 | $order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']); | 188 | $order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']); |
186 | if($order_detail_status1_count == 0){ | 189 | if($order_detail_status1_count == 0){ |
187 | $orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']); | 190 | $orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']); |
188 | } | 191 | } |
192 | + $order_info = $orderInfoModel->selectData(['order_detail_id'=>$data['id']]); | ||
193 | + } | ||
194 | + $goodsModel = new \app\index\model\Goods(); | ||
195 | + //扣除库存、增销量 | ||
196 | + foreach($order_info as $key => $o_i){ | ||
197 | +// $goods = $goodsModel->findData(['g.id'=>$o_i['goods_id']]); | ||
198 | + $goodsModel->where(['id'=>$o_i['goods_id']])->setDec('inventory',$o_i['number']); | ||
199 | + $goodsModel->where(['id'=>$o_i['goods_id']])->setInc('sale',$o_i['number']); | ||
189 | } | 200 | } |
190 | } | 201 | } |
191 | return true; // 返回处理完成 | 202 | return true; // 返回处理完成 |
-
请 注册 或 登录 后发表评论