ソースを参照

下单接口移动到Order模块中

wufeng 2 年 前
コミット
143641e242

+ 26 - 0
app/mobile/controller/Order.php

@@ -4,10 +4,36 @@ namespace app\mobile\controller;
 
 use app\BaseController;
 use app\mobile\logic\OrderLogic;
+use app\model\MasterOrderModel;
+use think\exception\ValidateException;
+use think\facade\Validate;
 
 //【订单】
 class Order extends BaseController
 {
+    //预下单
+    public function add()
+    {
+        $param = $this->request->only(['type', 'list', 'addr_id'], 'post');
+
+        $val = Validate::rule([
+            'type|购买类型' => 'require|number|in:' . MasterOrderModel::$type_exchange_good . ',' . MasterOrderModel::$type_shopping_good . ',' . MasterOrderModel::$type_service,
+            'list|购买列表' => 'require|array|max:100',
+            'addr_id|收货地址' => 'require|number|gt:0'
+        ]);
+        if (!$val->check($param)) throw new ValidateException($val->getError());
+
+        $val2 = Validate::rule([
+            'id' => 'require|number|gt:0',
+            'num|购买数量' => 'require|number|max:99999999',
+        ]);
+
+        foreach ($param['list'] as $list) {
+            if (!$val2->check($list)) throw new ValidateException($val2->getError());
+        }
+
+        return OrderLogic::add($param);
+    }
 
     //订单列表
     public function list(){

+ 0 - 25
app/mobile/controller/Pay.php

@@ -4,37 +4,12 @@ namespace app\mobile\controller;
 
 use app\BaseController;
 use app\mobile\logic\PayLogic;
-use app\model\CommonModel;
-use app\model\MasterOrderModel;
 use think\exception\ValidateException;
 use think\facade\Validate;
 
 //支付相关
 class Pay extends BaseController
 {
-    //预下单
-    public function getPrepayId()
-    {
-        $param = $this->request->only(['type', 'list', 'addr_id'], 'post');
-
-        $val = Validate::rule([
-            'type|购买类型' => 'require|number|in:' . MasterOrderModel::$type_exchange_good . ',' . MasterOrderModel::$type_shopping_good . ',' . MasterOrderModel::$type_service,
-            'list|购买列表' => 'require|array|max:100',
-            'addr_id|收货地址' => 'require|number|gt:0'
-        ]);
-        if (!$val->check($param)) throw new ValidateException($val->getError());
-
-        $val2 = Validate::rule([
-            'id' => 'require|number|gt:0',
-            'num|购买数量' => 'require|number|max:99999999',
-        ]);
-
-        foreach ($param['list'] as $list) {
-            if (!$val2->check($list)) throw new ValidateException($val2->getError());
-        }
-
-        return PayLogic::getPrepayId($param);
-    }
 
     //微信支付成功后的异步通知及订单处理
     public function Notify()

+ 291 - 0
app/mobile/logic/OrderLogic.php

@@ -2,12 +2,303 @@
 
 namespace app\mobile\logic;
 
+use app\model\AccountModel;
+use app\model\AddrModel;
 use app\model\CommonModel;
+use app\model\GoodModel;
+use app\model\InventoryExchangeModel;
+use app\model\MasterOrderModel;
 use app\model\OrderModel;
+use app\model\ServiceModel;
+use think\facade\Db;
+use think\Exception;
 use think\response\Json;
 
 class OrderLogic extends BaseLogic
 {
+    //下单
+    public static function add(array $data = []): json
+    {
+
+        Db::startTrans();
+
+        try {
+
+            $rs = AddrModel::field('id')
+                ->where(['is_del' => CommonModel::$del_normal, 'id' => $data['addr_id'], 'uid' => self::$aid])
+                ->findOrEmpty()
+                ->isEmpty();
+            if ($rs) throw new Exception('该地址不存在');
+
+            $amount = '0';//支付金额
+            $num = array_column($data['list'], 'num', 'id');//
+            $date = date('Y-m-d H:i:s');
+
+            $masterOrderCode = make_no('MS');
+
+            //主订单数据
+            $insert_master_order = [
+                'masterOrderCode' => $masterOrderCode,
+                'uid' => self::$aid,
+                'type' => $data['type'],
+                'createrid' => self::$aid,
+                'creater' => self::$aname,
+                'addtime' => $date,
+                'updaterid' => self::$aid,
+                'updater' => self::$aname,
+                'updatetime' => $date,
+            ];
+
+            //子订单数据
+            $insert_order = [];
+
+            //库存变动记录数据
+            $insert_inventory_exchange_log = [];
+
+
+            //兑换商品
+            if ($data['type'] == MasterOrderModel::$type_exchange_good) {
+
+                $rs = GoodModel::alias('a')
+                    ->leftJoin('inventory_exchange c', 'c.account_id=' . self::$aid . ' AND c.good_id=a.id')
+                    ->whereIn('a.id', array_column($data['list'], 'id'))
+                    ->where(['a.is_del' => CommonModel::$del_normal, 'a.status' => CommonModel::$status_normal, 'type' => GoodModel::$type_exchange])
+                    ->column('a.id,a.good_code,a.good_name,a.moq,c.inventory,c.id inventory_id', 'a.id');
+
+                if (empty($rs)) throw new Exception('购买的商品不存在或已禁用');
+
+                $i = 0;
+                $orderCode = make_no('QR');
+                $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
+                foreach ($rs as $item) {
+
+                    if ($item['moq'] > $num[$item['id']]) throw new Exception($item['good_name'] . '不满足起订量,' . $item['moq']);
+                    if ($item['inventory'] < $num[$item['id']]) throw new Exception($item['good_name'] . '的库存数不足');
+
+                    $insert_order[] = [
+                        'masterOrderCode' => $masterOrderCode,
+                        'orderCode' => $orderCode,
+                        'company_id' => self::$company_id,
+                        'card_id' => self::$card_id,
+                        'uid' => self::$aid,
+                        'child_id' => $item['id'],
+                        'num' => $num[$item['id']],
+                        'price' => 0,
+                        'total_price' => 0,
+                        'addr_id' => $data['addr_id'],
+                        'type' => $data['type'],
+                        'status' => MasterOrderModel::$order_status_not_deliver,
+                        'is_del' => CommonModel::$del_normal,
+                        'createrid' => self::$aid,
+                        'creater' => self::$aname,
+                        'addtime' => $date,
+                        'updaterid' => self::$aid,
+                        'updater' => self::$aname,
+                        'updatetime' => $date,
+                    ];
+
+                    //扣减库存
+                    $after_inventory = bcsub($item['inventory'], $num[$item['id']]);
+                    //添加库存变动记录
+                    $insert_inventory_exchange_log[] = [
+                        'inventory_exchange_id' => $item['inventory_id'],
+                        'before_inventory' => $item['inventory'],
+                        'after_inventory' => $after_inventory,
+                        'flag' => '-1',
+                        'good_id' => $item['id'],
+                        'good_code' => $item['good_code'],
+                        'good_name' => $item['good_name'],
+                        'source' => CommonModel::$source_account,
+                        'createrid' => self::$aid,
+                        'creater' => self::$aname,
+                        'addtime' => $date
+                    ];
+
+                    //扣减库存
+                    InventoryExchangeModel::where('id', $item['inventory_id'])
+                        ->save(['inventory' => $after_inventory, 'updaterid' => self::$aid, 'updater' => self::$aname, 'updatetime' => $date]);
+
+                    $i++;
+                }
+
+                //更新主订单表数据
+                $insert_master_order = array_merge($insert_master_order, [
+                    'wx_openId' => '',
+                    'prepay_info' => '',
+                    'amount' => $amount,
+                    'transaction_id' => '',
+                    'trade_type' => '',
+                    'notify_result' => '',
+                    'expiretime' => $date,
+                    'status' => MasterOrderModel::$order_status_not_deliver,
+                ]);
+
+                $res = ['is_need_pay' => 0, 'result' => ''];
+
+            } else {
+
+                $openId = AccountModel::where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal])
+                    ->value('wx_openId', '');
+
+                if ($openId == '') return json_show(CommonModel::$error_token, '获取账户openId失败,请重新登录');
+
+                switch ($data['type']) {
+
+                    //服务订单
+                    case MasterOrderModel::$type_service:
+                        $rs = ServiceModel::field('id,original_price,activity_price,title,activity_status')
+                            ->whereIn('id', array_column($data['list'], 'id'))
+                            ->where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal])
+                            ->select()
+                            ->toArray();
+                        if (empty($rs)) throw new Exception('购买的服务不存在或已下架');
+
+                        $i = 0;
+                        $orderCode = make_no('QR');
+                        $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
+                        foreach ($rs as $item) {
+                            //单价
+                            if ($item['activity_status'] == ServiceModel::$activity_status_ing) $price = $rs['activity_price'];
+                            else $price = $rs['original_price'];
+
+                            $total_price = bcmul($price, $num[$item['id']] ?? 0, 2);//总价
+                            $amount = bcadd($amount, $total_price, 2);//总金额
+
+                            $insert_order[] = [
+                                'masterOrderCode' => $masterOrderCode,
+                                'orderCode' => $orderCode,
+                                'company_id' => self::$company_id,
+                                'card_id' => self::$card_id,
+                                'uid' => self::$aid,
+                                'child_id' => $item['id'],
+                                'num' => $num[$item['id']] ?? 0,
+                                'price' => $price,
+                                'total_price' => $total_price,
+                                'addr_id' => $data['addr_id'],
+                                'type' => $data['type'],
+                                'status' => MasterOrderModel::$order_status_wait_pay,
+                                'is_del' => CommonModel::$del_normal,
+                                'createrid' => self::$aid,
+                                'creater' => self::$aname,
+                                'addtime' => $date,
+                                'updaterid' => self::$aid,
+                                'updater' => self::$aname,
+                                'updatetime' => $date,
+                            ];
+                            $i++;
+                        }
+
+
+                        break;
+
+                    //商城商品订单
+                    case MasterOrderModel::$type_shopping_good:
+                        $rs = GoodModel::alias('a')
+                            ->leftJoin('inventory_exchange c', 'c.account_id=' . self::$aid . ' AND c.good_id=a.id')
+                            ->whereIn('a.id', array_column($data['list'], 'id'))
+                            ->where(['a.is_del' => CommonModel::$del_normal, 'a.status' => CommonModel::$status_normal, 'type' => GoodModel::$type_shopping])
+                            ->column('a.id,a.good_code,a.good_name,a.moq,a.price,c.inventory,c.id inventory_id', 'a.id');
+
+                        if (empty($rs)) throw new Exception('购买的商品不存在或已禁用');
+
+                        $i = 0;
+                        $orderCode = make_no('QR');
+                        $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
+                        foreach ($rs as $item) {
+
+                            if ($item['moq'] > $num[$item['id']]) throw new Exception('不满足该商品的起订量,' . $item['moq']);
+                            if ($item['inventory'] < $num[$item['id']]) throw new Exception('库存数不足');
+
+                            $total_price = bcmul($rs['price'], $num[$item['id']] ?? 0, 2);//总价
+                            $amount = bcadd($amount, $total_price, 2);//总金额
+
+                            $order_insert[] = [
+                                'masterOrderCode' => $masterOrderCode,
+                                'orderCode' => $orderCode,
+                                'company_id' => self::$company_id,
+                                'card_id' => self::$card_id,
+                                'uid' => self::$aid,
+                                'child_id' => $item['id'],
+                                'num' => $num[$item['id']],
+                                'price' => $rs['price'],
+                                'total_price' => $total_price,
+                                'addr_id' => $data['addr_id'],
+                                'type' => $data['type'],
+                                'status' => MasterOrderModel::$order_status_wait_pay,
+                                'is_del' => CommonModel::$del_normal,
+                                'createrid' => self::$aid,
+                                'creater' => self::$aname,
+                                'addtime' => $date,
+                                'updaterid' => self::$aid,
+                                'updater' => self::$aname,
+                                'updatetime' => $date,
+                            ];
+
+
+                            //扣减库存
+                            $after_inventory = bcsub($item['inventory'], $num[$item['id']]);
+                            //添加库存变动记录
+                            $insert_inventory_exchange_log[] = [
+                                'inventory_exchange_id' => $item['inventory_id'],
+                                'before_inventory' => $item['inventory'],
+                                'after_inventory' => $after_inventory,
+                                'flag' => '-1',
+                                'good_id' => $item['id'],
+                                'good_code' => $item['good_code'],
+                                'good_name' => $item['good_name'],
+                                'source' => CommonModel::$source_account,
+                                'createrid' => self::$aid,
+                                'creater' => self::$aname,
+                                'addtime' => $date
+                            ];
+
+                            //扣减库存
+                            InventoryExchangeModel::where('id', $item['inventory_id'])
+                                ->save(['inventory' => $after_inventory, 'updaterid' => self::$aid, 'updater' => self::$aname, 'updatetime' => $date]);
+
+                            $i++;
+                        }
+
+                        break;
+                }
+
+                //获取预支付信息,
+                //@todo body要写什么????????
+                $result = WechatLogic::getPrepayId($openId, '', $masterOrderCode, $amount);
+
+
+                //更新主订单表数据
+                $insert_master_order = array_merge($insert_master_order, [
+                    'wx_openId' => $openId,
+                    'prepay_info' => '',//预支付信息
+                    'amount' => $amount,
+                    'transaction_id' => '',
+                    'trade_type' => '',
+                    'notify_result' => '',
+                    'expiretime' => $date,
+                    'status' => MasterOrderModel::$order_status_wait_pay,
+                ]);
+
+                $res = ['is_need_pay' => 1, 'result' => $result];
+
+            }
+
+
+            //处理数据
+            MasterOrderModel::create($insert_master_order)->save();
+            if ($insert_inventory_exchange_log) Db::name('inventory_exchange_log')->insertAll($insert_inventory_exchange_log);
+            if ($insert_order) Db::name('order')->insertAll($insert_order);
+
+            Db::commit();
+            return json_show(CommonModel::$success, '下单成功', $res);
+        } catch (Exception $exception) {
+            Db::rollback();
+            return json_show(CommonModel::$success, '下单失败,' . $exception->getMessage());
+        }
+
+
+    }
+
 
     //订单列表
     public static function list(array $data = []): Json

+ 0 - 286
app/mobile/logic/PayLogic.php

@@ -2,14 +2,10 @@
 
 namespace app\mobile\logic;
 
-use app\model\AccountModel;
-use app\model\AddrModel;
 use app\model\CommonModel;
 use app\model\GoodModel;
-use app\model\InventoryExchangeModel;
 use app\model\MasterOrderModel;
 use app\model\PayInfoModel;
-use app\model\ServiceModel;
 use think\Exception;
 use think\facade\Db;
 use think\response\Json;
@@ -17,288 +13,6 @@ use think\response\Json;
 class PayLogic extends BaseLogic
 {
 
-    //下单
-    public static function getPrepayId(array $data = []): json
-    {
-
-        Db::startTrans();
-
-        try {
-
-            $rs = AddrModel::field('id')
-                ->where(['is_del' => CommonModel::$del_normal, 'id' => $data['addr_id'], 'uid' => self::$aid])
-                ->findOrEmpty()
-                ->isEmpty();
-            if ($rs) throw new Exception('该地址不存在');
-
-            $amount = '0';//支付金额
-            $num = array_column($data['list'], 'num', 'id');//
-            $date = date('Y-m-d H:i:s');
-
-            $masterOrderCode = make_no('MS');
-
-            //主订单数据
-            $insert_master_order = [
-                'masterOrderCode' => $masterOrderCode,
-                'uid' => self::$aid,
-                'type' => $data['type'],
-                'createrid' => self::$aid,
-                'creater' => self::$aname,
-                'addtime' => $date,
-                'updaterid' => self::$aid,
-                'updater' => self::$aname,
-                'updatetime' => $date,
-            ];
-
-            //子订单数据
-            $insert_order = [];
-
-            //库存变动记录数据
-            $insert_inventory_exchange_log = [];
-
-
-            //兑换商品
-            if ($data['type'] == MasterOrderModel::$type_exchange_good) {
-
-                $rs = GoodModel::alias('a')
-                    ->leftJoin('inventory_exchange c', 'c.account_id=' . self::$aid . ' AND c.good_id=a.id')
-                    ->whereIn('a.id', array_column($data['list'], 'id'))
-                    ->where(['a.is_del' => CommonModel::$del_normal, 'a.status' => CommonModel::$status_normal, 'type' => GoodModel::$type_exchange])
-                    ->column('a.id,a.good_code,a.good_name,a.moq,c.inventory,c.id inventory_id', 'a.id');
-
-                if (empty($rs)) throw new Exception('购买的商品不存在或已禁用');
-
-                $i = 0;
-                $orderCode = make_no('QR');
-                $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
-                foreach ($rs as $item) {
-
-                    if ($item['moq'] > $num[$item['id']]) throw new Exception($item['good_name'] . '不满足起订量,' . $item['moq']);
-                    if ($item['inventory'] < $num[$item['id']]) throw new Exception($item['good_name'] . '的库存数不足');
-
-                    $insert_order[] = [
-                        'masterOrderCode' => $masterOrderCode,
-                        'orderCode' => $orderCode,
-                        'company_id' => self::$company_id,
-                        'card_id' => self::$card_id,
-                        'uid' => self::$aid,
-                        'child_id' => $item['id'],
-                        'num' => $num[$item['id']],
-                        'price' => 0,
-                        'total_price' => 0,
-                        'addr_id' => $data['addr_id'],
-                        'type' => $data['type'],
-                        'status' => MasterOrderModel::$order_status_not_deliver,
-                        'is_del' => CommonModel::$del_normal,
-                        'createrid' => self::$aid,
-                        'creater' => self::$aname,
-                        'addtime' => $date,
-                        'updaterid' => self::$aid,
-                        'updater' => self::$aname,
-                        'updatetime' => $date,
-                    ];
-
-                    //扣减库存
-                    $after_inventory = bcsub($item['inventory'], $num[$item['id']]);
-                    //添加库存变动记录
-                    $insert_inventory_exchange_log[] = [
-                        'inventory_exchange_id' => $item['inventory_id'],
-                        'before_inventory' => $item['inventory'],
-                        'after_inventory' => $after_inventory,
-                        'flag' => '-1',
-                        'good_id' => $item['id'],
-                        'good_code' => $item['good_code'],
-                        'good_name' => $item['good_name'],
-                        'source' => CommonModel::$source_account,
-                        'createrid' => self::$aid,
-                        'creater' => self::$aname,
-                        'addtime' => $date
-                    ];
-
-                    //扣减库存
-                    InventoryExchangeModel::where('id', $item['inventory_id'])
-                        ->save(['inventory' => $after_inventory, 'updaterid' => self::$aid, 'updater' => self::$aname, 'updatetime' => $date]);
-
-                    $i++;
-                }
-
-                //更新主订单表数据
-                $insert_master_order = array_merge($insert_master_order, [
-                    'wx_openId' => '',
-                    'prepay_info' => '',
-                    'amount' => $amount,
-                    'transaction_id' => '',
-                    'trade_type' => '',
-                    'notify_result' => '',
-                    'expiretime' => $date,
-                    'status' => MasterOrderModel::$order_status_not_deliver,
-                ]);
-
-                $res = ['is_need_pay' => 0, 'result' => ''];
-
-            } else {
-
-                $openId = AccountModel::where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal])
-                    ->value('wx_openId', '');
-
-                if ($openId == '') return json_show(CommonModel::$error_token, '获取账户openId失败,请重新登录');
-
-                switch ($data['type']) {
-
-                    //服务订单
-                    case MasterOrderModel::$type_service:
-                        $rs = ServiceModel::field('id,original_price,activity_price,title,activity_status')
-                            ->whereIn('id', array_column($data['list'], 'id'))
-                            ->where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal])
-                            ->select()
-                            ->toArray();
-                        if (empty($rs)) throw new Exception('购买的服务不存在或已下架');
-
-                        $i = 0;
-                        $orderCode = make_no('QR');
-                        $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
-                        foreach ($rs as $item) {
-                            //单价
-                            if ($item['activity_status'] == ServiceModel::$activity_status_ing) $price = $rs['activity_price'];
-                            else $price = $rs['original_price'];
-
-                            $total_price = bcmul($price, $num[$item['id']] ?? 0, 2);//总价
-                            $amount = bcadd($amount, $total_price, 2);//总金额
-
-                            $insert_order[] = [
-                                'masterOrderCode' => $masterOrderCode,
-                                'orderCode' => $orderCode,
-                                'company_id' => self::$company_id,
-                                'card_id' => self::$card_id,
-                                'uid' => self::$aid,
-                                'child_id' => $item['id'],
-                                'num' => $num[$item['id']] ?? 0,
-                                'price' => $price,
-                                'total_price' => $total_price,
-                                'addr_id' => $data['addr_id'],
-                                'type' => $data['type'],
-                                'status' => MasterOrderModel::$order_status_wait_pay,
-                                'is_del' => CommonModel::$del_normal,
-                                'createrid' => self::$aid,
-                                'creater' => self::$aname,
-                                'addtime' => $date,
-                                'updaterid' => self::$aid,
-                                'updater' => self::$aname,
-                                'updatetime' => $date,
-                            ];
-                            $i++;
-                        }
-
-
-                        break;
-
-                    //商城商品订单
-                    case MasterOrderModel::$type_shopping_good:
-                        $rs = GoodModel::alias('a')
-                            ->leftJoin('inventory_exchange c', 'c.account_id=' . self::$aid . ' AND c.good_id=a.id')
-                            ->whereIn('a.id', array_column($data['list'], 'id'))
-                            ->where(['a.is_del' => CommonModel::$del_normal, 'a.status' => CommonModel::$status_normal, 'type' => GoodModel::$type_shopping])
-                            ->column('a.id,a.good_code,a.good_name,a.moq,a.price,c.inventory,c.id inventory_id', 'a.id');
-
-                        if (empty($rs)) throw new Exception('购买的商品不存在或已禁用');
-
-                        $i = 0;
-                        $orderCode = make_no('QR');
-                        $orderCode = substr($orderCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
-                        foreach ($rs as $item) {
-
-                            if ($item['moq'] > $num[$item['id']]) throw new Exception('不满足该商品的起订量,' . $item['moq']);
-                            if ($item['inventory'] < $num[$item['id']]) throw new Exception('库存数不足');
-
-                            $total_price = bcmul($rs['price'], $num[$item['id']] ?? 0, 2);//总价
-                            $amount = bcadd($amount, $total_price, 2);//总金额
-
-                            $order_insert[] = [
-                                'masterOrderCode' => $masterOrderCode,
-                                'orderCode' => $orderCode,
-                                'company_id' => self::$company_id,
-                                'card_id' => self::$card_id,
-                                'uid' => self::$aid,
-                                'child_id' => $item['id'],
-                                'num' => $num[$item['id']],
-                                'price' => $rs['price'],
-                                'total_price' => $total_price,
-                                'addr_id' => $data['addr_id'],
-                                'type' => $data['type'],
-                                'status' => MasterOrderModel::$order_status_wait_pay,
-                                'is_del' => CommonModel::$del_normal,
-                                'createrid' => self::$aid,
-                                'creater' => self::$aname,
-                                'addtime' => $date,
-                                'updaterid' => self::$aid,
-                                'updater' => self::$aname,
-                                'updatetime' => $date,
-                            ];
-
-
-                            //扣减库存
-                            $after_inventory = bcsub($item['inventory'], $num[$item['id']]);
-                            //添加库存变动记录
-                            $insert_inventory_exchange_log[] = [
-                                'inventory_exchange_id' => $item['inventory_id'],
-                                'before_inventory' => $item['inventory'],
-                                'after_inventory' => $after_inventory,
-                                'flag' => '-1',
-                                'good_id' => $item['id'],
-                                'good_code' => $item['good_code'],
-                                'good_name' => $item['good_name'],
-                                'source' => CommonModel::$source_account,
-                                'createrid' => self::$aid,
-                                'creater' => self::$aname,
-                                'addtime' => $date
-                            ];
-
-                            //扣减库存
-                            InventoryExchangeModel::where('id', $item['inventory_id'])
-                                ->save(['inventory' => $after_inventory, 'updaterid' => self::$aid, 'updater' => self::$aname, 'updatetime' => $date]);
-
-                            $i++;
-                        }
-
-                        break;
-                }
-
-                //获取预支付信息,
-                //@todo body要写什么????????
-                $result = WechatLogic::getPrepayId($openId, '', $masterOrderCode, $amount);
-
-
-                //更新主订单表数据
-                $insert_master_order = array_merge($insert_master_order, [
-                    'wx_openId' => $openId,
-                    'prepay_info' => '',//预支付信息
-                    'amount' => $amount,
-                    'transaction_id' => '',
-                    'trade_type' => '',
-                    'notify_result' => '',
-                    'expiretime' => $date,
-                    'status' => MasterOrderModel::$order_status_wait_pay,
-                ]);
-
-                $res = ['is_need_pay' => 1, 'result' => $result];
-
-            }
-
-
-            //处理数据
-            MasterOrderModel::create($insert_master_order)->save();
-            if ($insert_inventory_exchange_log) Db::name('inventory_exchange_log')->insertAll($insert_inventory_exchange_log);
-            if ($insert_order) Db::name('order')->insertAll($insert_order);
-
-            Db::commit();
-            return json_show(CommonModel::$success, '下单成功', $res);
-        } catch (Exception $exception) {
-            Db::rollback();
-            return json_show(CommonModel::$success, '下单失败,' . $exception->getMessage());
-        }
-
-
-    }
 
     //微信支付成功后的异步通知及订单处理
     public static function Notify()

+ 1 - 2
app/mobile/route/app.php

@@ -10,7 +10,6 @@ Route::rule('updatePassword', 'Account/updatePassword');//修改密码
 Route::rule('bindAccountByCode', 'Account/bindAccountByCode');//通过微信端code绑定账户
 
 //【支付】
-Route::rule('getPrepayId', 'Pay/getPrepayId');//微信支付预下单
 Route::rule('notify', 'Pay/Notify');//微信支付成功后的异步通知及订单处理
 Route::rule('checkPayResult', 'Pay/checkPayResult');//检查支付结果
 
@@ -38,7 +37,7 @@ Route::rule('shoppingGoodList', 'Shopping/goodList');//商城商品列表
 Route::rule('shoppingGoodInfo', 'Shopping/goodInfo');//商城商品详情
 
 //【订单】
-Route::rule('orderAdd', 'Order/add');//兑换商品下单
+Route::rule('orderAdd', 'Order/add');//下单
 Route::rule('orderList', 'Order/list');//订单列表
 Route::rule('orderInfo', 'Order/info');//订单详情