소스 검색

Merge branch 'dev_wf' of wugg/phpstock into version1.5

wufeng 2 년 전
부모
커밋
90ad5335a2
2개의 변경된 파일89개의 추가작업 그리고 34개의 파일을 삭제
  1. 87 33
      app/admin/controller/OrderImport.php
  2. 2 1
      app/admin/route/app.php

+ 87 - 33
app/admin/controller/OrderImport.php

@@ -13,57 +13,111 @@ class OrderImport extends Base
 {
 
     //订单导入
-    public function import(){
-
-        $list = $this->request->post('list',[],'trim');
-
-        $val = Validate::rule([
-            'platform_code|平台订单号'=>'require|length:0,255',
-            'po_code|其他单号'=>'length:0,255',
-            'platform_time|平台下单时间'=>'require|date',
-            'sale_source|销售渠道'=>'require|length:0,255',
-            'good_code|商品编号'=>'require|length:0,255',
-            'price|单价'=>'require|float',
-            'num|数量'=>'require|number',
-            'before_discount_all_price|优惠前总金额'=>'require|float',
-            'discount_price|优惠金额'=>'require|float',
-            'after_price|商品优惠后金额'=>'require|float',
-            'activity_name|优惠活动名称'=>'require|length:0,255',
-            'mode|收费模式'=>'require|length:0,255',
-            'order_remark|订单备注'=>'length:0,255',
-            'contactor|收货人'=>'require|length:0,255',
-            'mobile|联系电话'=>'require|length:0,20',
-            'addr|联系地址'=>'require|length:0,255',
-        ]);
+    public function import()
+    {
+
+        $param = $this->request->only(['token', 'list'], 'post', 'trim');
+
+        $val_params = Validate::rule(['token' => 'require', 'list' => 'require|array']);
+
+        if (!$val_params->check($param)) throw new \think\Exception($val_params->getError());
 
         Db::startTrans();
 
-        try{
+        try {
+
+            $userinfo = GetUserInfo($param['token']);
+            $createrid = isset($user["data"]['id']) ? $userinfo["data"]['id'] : 0;
+            $creater = isset($user["data"]['nickname']) ? $userinfo["data"]['nickname'] : "";
 
-            $insert_data=[];
-            foreach ($list as $key=>$value){
-                if(!$val->check($value)) throw new \think\Exception('第'.(string)($key+1).'行数据格式有问题,'.$val->getError());
-                else $insert_data[]=$value;
+
+            $val = Validate::rule([
+                'platform_code|平台订单号' => 'require|length:0,255',
+                'po_code|其他单号' => 'length:0,255',
+                'platform_time|平台下单时间' => 'require|date',
+                'sale_source|销售渠道' => 'require|length:0,255',
+                'good_code|商品编号' => 'require|length:0,255',
+                'price|单价' => 'require|float',
+                'num|数量' => 'require|number',
+                'before_discount_all_price|优惠前总金额' => 'require|float',
+                'discount_price|优惠金额' => 'require|float',
+                'after_price|商品优惠后金额' => 'require|float',
+                'activity_name|优惠活动名称' => 'require|length:0,255',
+                'mode|收费模式' => 'require|length:0,255',
+                'order_remark|订单备注' => 'length:0,255',
+                'contactor|收货人' => 'require|length:0,255',
+                'mobile|联系电话' => 'require|length:0,20',
+                'addr|联系地址' => 'require|length:0,255',
+            ]);
+
+            $insert_data = [];
+            foreach ($param['list'] as $key => $value) {
+                if (!$val->check($value)) throw new \think\Exception('第' . (string)($key + 1) . '行数据格式有问题,' . $val->getError());
+                else {
+                    $value['createrid'] = $createrid;
+                    $value['creater'] = $creater;
+                    $insert_data[] = $value;
+                }
             }
 
             $res = Db::name('order_import_from_c')
                 ->limit(100)
                 ->insertAll($insert_data);
 
-            if($res){
+            if ($res) {
                 Db::commit();
-                return app_show(0, "导入成功,共".(string)$res.'条记录');
-            }else{
+                return app_show(0, "导入成功,共" . (string)$res . '条记录');
+            } else {
                 Db::rollback();
 
-                return error_show(1005,'导入失败');
+                return error_show(1005, '导入失败');
             }
 
-        }catch (Exception $exception){
+        } catch (Exception $exception) {
             Db::rollback();
-            return error_show(1005,$exception->getMessage());
+            return error_show(1005, $exception->getMessage());
         }
 
     }
 
+
+    //查看订单录入列表
+    public function getImportList()
+    {
+
+        $param = $this->request->only([
+            'status' => 0,
+            'platform_code' => '',
+            'po_code' => '',
+            'platform_time_start' => '',
+            'platform_time_end' => '',
+            'addtime_start' => '',
+            'addtime_end' => '',
+            'good_code' => '',
+            'page' => 1,
+            'size' => 15,
+        ], 'post', 'trim');
+
+        $where = [];
+        if ($param['status']) $where[] = ['c.status', '=', $param['status']];
+        if ($param['platform_code']) $where[] = ['c.platform_code', 'like', '%' . $param['platform_code'] . '%'];
+        if ($param['po_code']) $where[] = ['c.po_code', 'like', '%' . $param['po_code'] . '%'];
+        if ($param['platform_time_start'] && $param['platform_time_end']) $where[] = ['c.platform_time', 'between', [$param['platform_time_start'], $param['platform_time_end']]];
+        if ($param['addtime_start'] && $param['addtime_end']) $where[] = ['c.addtime', 'between', [$param['addtime_start'], $param['addtime_end']]];
+        if ($param['good_code']) $where[] = ['c.good_code', 'like', '%' . $param['good_code'] . '%'];
+
+        $db = OIFCModel::alias('c')->where($where);
+
+        $total = $db->count('id');
+
+        $list = $db
+            ->page($param['page'], $param['size'])
+            ->order('id', 'desc')
+            ->select()
+            ->toArray();
+
+        return app_show(0, "获取成功", ['list' => $list, 'count' => $total]);
+    }
+
+
 }

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

@@ -468,4 +468,5 @@ Route::rule("projectsharecheck","admin/Version/feedCheck");
 Route::rule("plancheck","admin/Version/planCheck");
 
 Route::rule('getdata','admin/Data/index');//数据看板,获取相关统计数据
-Route::rule('orderimport','admin/OrderImport/import');//C端订单导入
+Route::rule('orderimport','admin/OrderImport/import');//C端订单导入
+Route::rule('orderimportlist','admin/OrderImport/getImportList');//C端订单列表