作者 王晓刚
1 个管道 的构建 通过 耗费 23 秒

合并分支 'wxg' 到 'master'

Wxg



查看合并请求 !71
... ... @@ -97,9 +97,15 @@ class Car extends Frontend
if(empty($car)){
//新增
//判断库存是否充足
if($data['inventory'] < 1){
if($data['inventory'] < $car['number']+$number){
$this->error("商品 【$data[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($data['is_impose'] == '1'){
if($data['imposenum'] < $car['number']+$number){
$this->error("商品 【$data[goodsname]】 超出限购数量~");
}
}
$arr['createtime'] = time();
$result = $carModel->insertData($arr);
}else{
... ... @@ -108,9 +114,15 @@ class Car extends Frontend
if($type == 1){
//增加数量
//判断库存是否充足
if($data['inventory'] < 1){
if($data['inventory'] < $car['number']+$number){
$this->error("商品 【$data[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($data['is_impose'] == '1'){
if($data['imposenum'] < $car['number']+$number){
$this->error("商品 【$data[goodsname]】 超出限购数量~");
}
}
$result = $carModel->where(['id'=>$car['id']])->setInc('number',$number);
}else{
//减少数量
... ...
... ... @@ -97,6 +97,9 @@ class Member extends Frontend
];
if($param['status']) {
$where['status'] = $param['status'];
if($param['status']==5){
$where['status'] = ['in',['5','6','8','11']];
}
}
$order = $order_detail_model
->where($where)
... ... @@ -387,7 +390,7 @@ class Member extends Frontend
'10' => '已删除',
];
$order['store_name'] = $store_model->where('id',$order['store_id'])->value('name');
$order['goods'] = $order_info_model->where('order_id',$order['id'])->select();
$order['goods'] = $order_info_model->where('order_detail_id',$order['id'])->select();
$order['status'] = $status[$order['status']];
$this->view->assign('order',$order);
return $this->view->fetch();
... ...
... ... @@ -11,6 +11,7 @@ namespace app\index\controller;
use app\common\controller\Api;
use app\common\controller\Frontend;
use app\index\model\OrderDetail;
use app\index\model\OrderInfo;
use app\index\model\Store;
use app\index\model\Viporder;
use think\Db;
... ... @@ -94,6 +95,7 @@ class Notify extends Frontend
$identification = substr($out_trade_no, -1);
$orderModel = new \app\index\model\Order();
$orderDetailModel = new OrderDetail();
$orderInfoModel = new OrderInfo();
if($identification == 1){
$data = $orderModel->findData(['num'=>$out_trade_no]);
}else{
... ... @@ -113,12 +115,21 @@ class Notify extends Frontend
if($identification == 1){
$orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$order_info = $orderInfoModel->selectData(['order_id'=>$data['id']]);
}else{
$orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']);
if($order_detail_status1_count == 0){
$orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']);
}
$order_info = $orderInfoModel->selectData(['order_detail_id'=>$data['id']]);
}
$goodsModel = new \app\index\model\Goods();
//扣除库存、增销量
foreach($order_info as $key => $o_i){
// $goods = $goodsModel->findData(['g.id'=>$o_i['goods_id']]);
$goodsModel->where(['id'=>$o_i['goods_id']])->setDec('inventory',$o_i['number']);
$goodsModel->where(['id'=>$o_i['goods_id']])->setInc('sale',$o_i['number']);
}
}
return true; // 返回处理完成
... ...
... ... @@ -96,6 +96,12 @@ class Order extends Frontend
if($goods['inventory'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($goods['is_impose'] == '1'){
if($goods['imposenum'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 超出限购数量~");
}
}
$goods['number'] = $number[$key4];
$goods_price[] = $goods['price']*$number[$key4];
$goods_arr[] = $goods;
... ... @@ -215,6 +221,12 @@ class Order extends Frontend
if($goods['inventory'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($goods['is_impose'] == '1'){
if($goods['imposenum'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 超出限购数量~");
}
}
$goods['number'] = $number[$key4];
$goods_price[] = $goods['price']*$number[$key4];
$goods_arr[] = $goods;
... ... @@ -322,6 +334,12 @@ class Order extends Frontend
if($goods['inventory'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($goods['is_impose'] == '1'){
if($goods['imposenum'] < $number[$key4]){
$this->error("商品 【$goods[goodsname]】 超出限购数量~");
}
}
$goods['number'] = $number[$key4];
$goods_price[] = $goods['price']*$number[$key4];
$goods_arr[] = $goods;
... ... @@ -453,6 +471,12 @@ class Order extends Frontend
if($goods['inventory'] < $o_i['number']){
$this->error("商品 【$goods[goodsname]】 库存不足~");
}
//是否超出商品限购数量
if($goods['is_impose'] == '1'){
if($goods['imposenum'] < $o_i['number']){
$this->error("商品 【$goods[goodsname]】 超出限购数量~");
}
}
}
if($data['pay_type'] == '1'){
//微信支付
... ...
... ... @@ -4,6 +4,7 @@ namespace app\index\controller;
use app\common\controller\HomeBase;
use app\index\model\OrderDetail;
use app\index\model\OrderInfo;
use app\index\model\Store;
use app\index\model\Viporder;
use EasyWeChat\Foundation\Application;
... ... @@ -162,6 +163,7 @@ class WechatPay extends HomeBase
$identification = substr($out_trade_no, -1);
$orderModel = new \app\index\model\Order();
$orderDetailModel = new OrderDetail();
$orderInfoModel = new OrderInfo();
if($identification == 1){
$data = $orderModel->findData(['num'=>$out_trade_no]);
}else{
... ... @@ -180,12 +182,21 @@ class WechatPay extends HomeBase
if($identification == 1){
$orderModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$orderDetailModel->updateData(['order_id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$order_info = $orderInfoModel->selectData(['order_id'=>$data['id']]);
}else{
$orderDetailModel->updateData(['id'=>$data['id']],['paytime'=>time(),'status'=>'2']);
$order_detail_status1_count = $orderDetailModel->findData(['order_id'=>$data['order_id'],'status'=>'1']);
if($order_detail_status1_count == 0){
$orderModel->updateData(['id'=>$data['order_id']],['paytime'=>time(),'status'=>'2']);
}
$order_info = $orderInfoModel->selectData(['order_detail_id'=>$data['id']]);
}
$goodsModel = new \app\index\model\Goods();
//扣除库存、增销量
foreach($order_info as $key => $o_i){
// $goods = $goodsModel->findData(['g.id'=>$o_i['goods_id']]);
$goodsModel->where(['id'=>$o_i['goods_id']])->setDec('inventory',$o_i['number']);
$goodsModel->where(['id'=>$o_i['goods_id']])->setInc('sale',$o_i['number']);
}
}
return true; // 返回处理完成
... ...