瀏覽代碼

平台商品号不允许重复

wufeng 2 年之前
父節點
當前提交
e2fd6e13d2
共有 1 個文件被更改,包括 14 次插入4 次删除
  1. 14 4
      app/admin/controller/OrderImport.php

+ 14 - 4
app/admin/controller/OrderImport.php

@@ -3,7 +3,7 @@
 namespace app\admin\controller;
 
 use app\admin\model\OrderImportFromC as OIFCModel;
-use Exception;
+use think\Exception;
 use think\facade\Config;
 use think\facade\Db;
 use think\facade\Validate;
@@ -20,12 +20,22 @@ class OrderImport extends Base
 
         $val_params = Validate::rule(['token' => 'require', 'list' => 'require|array']);
 
-        if (!$val_params->check($param)) throw new \think\Exception($val_params->getError());
+        if (!$val_params->check($param)) throw new Exception($val_params->getError());
 
         Db::startTrans();
 
         try {
 
+            //平台订单号不允许重复
+            $all_platform_codes = array_column($param['list'], 'platform_code');
+
+            $temp = Db::name('order_import_from_c')
+                ->field('id,platform_code')
+                ->whereIn('platform_code', $all_platform_codes)
+                ->find();
+
+            if (!empty($temp)) throw new Exception('平台订单号' . $temp['platform_code'] . '重复');
+
             $userinfo = GetUserInfo($param['token']);
             $createrid = isset($user["data"]['id']) ? $userinfo["data"]['id'] : 0;
             $creater = isset($user["data"]['nickname']) ? $userinfo["data"]['nickname'] : "";
@@ -215,7 +225,7 @@ class OrderImport extends Base
             $rs = Db::name('order_import_from_c')
                 ->where(['id' => $param['id'], 'is_del' => OIFCModel::$is_del_normal, 'status' => OIFCModel::$status_wait_confirm])
                 ->find();
-            if (empty($rs)) throw new \think\Exception('该记录不存在或不允许用户确认');
+            if (empty($rs)) throw new Exception('该记录不存在或不允许用户确认');
 
             $userinfo = GetUserInfo($param['token']);
 
@@ -258,7 +268,7 @@ class OrderImport extends Base
 
             return app_show(0, '修改成功');
 
-        } catch (\think\Exception $exception) {
+        } catch (Exception $exception) {
 
             Db::rollback();