cqp преди 3 месеца
родител
ревизия
b67aeeee06

+ 76 - 0
app/Http/Controllers/Api/OrderController.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use App\Service\OrderService;
+use Illuminate\Http\Request;
+
+class OrderController extends BaseController
+{
+    public function orderEdit(Request $request)
+    {
+        $service = new OrderService();
+        $user = $request->userData;
+        list($status,$data) = $service->orderEdit($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function orderAdd(Request $request)
+    {
+        $service = new OrderService();
+        $user = $request->userData;
+        list($status,$data) = $service->orderAdd($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function orderDel(Request $request)
+    {
+        $service = new OrderService();
+        $user = $request->userData;
+        list($status,$data) = $service->orderDel($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function orderList(Request $request)
+    {
+        $service = new OrderService();
+        $user = $request->userData;
+        list($status,$data) = $service->orderList($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function orderDetail(Request $request)
+    {
+        $service = new OrderService();
+        $user = $request->userData;
+        list($status,$data) = $service->orderDetail($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+}

+ 3 - 7
app/Http/Controllers/Api/WeixinController.php

@@ -8,23 +8,19 @@ use Illuminate\Http\Request;
 
 class WeixinController extends BaseController
 {
-    //开发者密码:
     /**
-     * 用于微信token验证,全部通用,前提token都为qingyao
+     * 用于微信服务号token验证
      * @param Request $request
      * @return void
      */
-    public function weixin(Request $request)
+    public function wechatH5(Request $request)
     {
         file_put_contents('1.txt',json_encode($request->all()));
-//        die('adsds');
-//        $data = json_decode('{"signature":"fe04bfbb92a1c073e9f0829d3c4e48e1b40403aa","echostr":"5841396639871246203","timestamp":"1695188315","nonce":"1459788183"}',true);
         $data = $request->all();
         $signature = $data["signature"];
         $timestamp = $data["timestamp"];
         $nonce = $data["nonce"];
-
-        $token = 'qingyao';
+        $token = env('Wechat_Token');
         $tmpArr = array($token, $timestamp, $nonce);
         sort($tmpArr, SORT_STRING);
         $tmpStr = implode( $tmpArr );

+ 0 - 86
app/Http/Controllers/Api/WxController.php

@@ -2,11 +2,7 @@
 
 namespace App\Http\Controllers\Api;
 
-use App\Service\PurchaseOrderService;
-use App\Service\SalesOrderService;
-use App\Service\Weixin\WeixinService;
 use App\Service\Wx\WxEmployeeService;
-use App\Service\Wx\WxService;
 use Illuminate\Http\Request;
 
 class WxController extends BaseController
@@ -34,86 +30,4 @@ class WxController extends BaseController
             return $this->json_return(201, $data);
         }
     }
-
-    public function login(Request $request)
-    {
-        $service = new WxEmployeeService();
-        list($status, $data) = $service->login($request->all());
-
-        if ($status) {
-            return $this->json_return(200, '', $data);
-        } else {
-            return $this->json_return(201, $data);
-        }
-    }
-
-    public function saleOrderList(Request $request){
-        $service = new SalesOrderService();
-        $userData = $request->userData;
-        list($status,$data) = $service->salesOrderListsalesOrderWxList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-
-    public function purchaseOrderList(Request $request){
-        $service = new PurchaseOrderService();
-        $userData = $request->userData;
-        list($status,$data) = $service->getList($request->all(),$userData);
-
-        if($status){
-            return $this->json_return(200,'',$data);
-        }else{
-            return $this->json_return(201,$data);
-        }
-    }
-    public function wxH5(Request $request){
-        file_put_contents('1.txt',json_encode($request->all()));
-//        die('adsds');
-//        $data = json_decode('{"signature":"fe04bfbb92a1c073e9f0829d3c4e48e1b40403aa","echostr":"5841396639871246203","timestamp":"1695188315","nonce":"1459788183"}',true);
-        $data = $request->all();
-        $signature = $data["signature"];
-        $timestamp = $data["timestamp"];
-        $nonce = $data["nonce"];
-
-        $token = 'qingyaokeji';
-        $tmpArr = array($token, $timestamp, $nonce);
-        sort($tmpArr, SORT_STRING);
-        $tmpStr = implode( $tmpArr );
-        $tmpStr = sha1( $tmpStr );
-//        var_dump($tmpStr);
-//        var_dump($signature);die;
-        if( $tmpStr == $signature && isset($data['echostr']) ){
-            echo $data['echostr'];die;
-        }else{
-            die('fail');
-        }
-    }
-
-    public function ttt(){
-        $a = new WxService();
-        //[88,1,0,37,["T9XX.20240502","\u5f85\u5ba1\u6838","\u8d85\u7ea7\u7ba1\u7406\u5458","\u8ba2\u5355\u5408\u540c","2024-05-02 02:50:04"]]
-        $user_id = 88;
-        $type = 1;
-        $state = 0;
-        $menu_id = 37;
-        $order_data = json_decode('["刁法森","\u5201\u6cd5\u68ee","2024-05-02 03:09:36","T9XX.202405020249365948(\u8ba2\u5355\u5408\u540c)"]',true);
-        $a = $a->wx_sendMsg($user_id,$type,$state,$menu_id,$order_data);
-
-        return $a;
-    }
-
-    public function getTopMessage(Request $request){
-        $service = new WxEmployeeService();
-        list($status, $data) = $service->getTopMessage($request->all());
-
-        if ($status) {
-            return $this->json_return(200, '', $data);
-        } else {
-            return $this->json_return(202, $data);
-        }
-    }
 }

+ 1 - 1
app/Http/Middleware/CheckWeinxin.php

@@ -11,7 +11,7 @@ class CheckWeinxin
 {
     /**
      * Handle an incoming request.
-     *
+     * 微信公众号中间件
      * @param  Request  $request
      * @param Closure $next
      * @return mixed

+ 1 - 1
app/Http/Middleware/CheckWx.php

@@ -13,7 +13,7 @@ class CheckWx
 {
     /**
      * Handle an incoming request.
-     *
+     * 微信小程序中间件
      * @param  \Illuminate\Http\Request  $request
      * @param  \Closure  $next
      * @return mixed

+ 1 - 3
app/Model/CustomerSupply.php

@@ -2,9 +2,7 @@
 
 namespace App\Model;
 
-use Illuminate\Database\Eloquent\Model;
-
-class CustomerSupply extends Model
+class CustomerSupply extends UseScopeBaseModel
 {
     protected $guarded = [];
     protected $table = "customer_supply"; //指定表

+ 3 - 2
app/Model/GiveOut.php

@@ -2,12 +2,13 @@
 
 namespace App\Model;
 
-class GiveOut extends UseScopeBaseModel
+use Illuminate\Database\Eloquent\Model;
+
+class GiveOut extends Model
 {
     protected $table = "give_out"; //指定表
     const CREATED_AT = 'crt_time';
     const UPDATED_AT = 'upd_time';
-    const employee_column = 'employee_id_1';
     protected $dateFormat = 'U';
 
     public static $field = ['give_out_amount','id','mark','employee_id_1','employee_id_1_title','send_time','start_time','end_time'];

+ 16 - 0
app/Model/Order.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Model;
+
+class Order extends UseScopeBaseModel
+{
+    protected $guarded = [];
+    protected $table = "order"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    const employee_column = "crt_id";
+
+    public static $field = ['order_number','id','customer_id','supply_id','crt_time','order_time','crt_id','quantity'];
+
+    protected $dateFormat = 'U';
+}

+ 14 - 0
app/Model/OrderDetails.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrderDetails extends Model
+{
+    protected $guarded = [];
+    protected $table = "order_details"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+}

+ 12 - 14
app/Service/CustomerSupplyService.php

@@ -22,7 +22,6 @@ class CustomerSupplyService extends Service
             $model->title = $data['title'] ?? '';
             $model->type = $data['type'] ?? 0;
             $model->status = $data['status'] ?? 0;
-            $model->address = $data['address'] ?? "";
             $model->year = $data['year'] ?? 0;
             $model->first_scene = $data['first_scene'] ?? "";
             $model->business = $data['business'] ?? "";
@@ -65,7 +64,6 @@ class CustomerSupplyService extends Service
             $model->title = $data['title'] ?? '';
             $model->type = $data['type'] ?? 0;
             $model->status = $data['status'] ?? 0;
-            $model->address = $data['address'] ?? "";
             $model->year = $data['year'] ?? 0;
             $model->first_scene = $data['first_scene'] ?? "";
             $model->business = $data['business'] ?? "";
@@ -207,6 +205,7 @@ class CustomerSupplyService extends Service
         if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
         if(! empty($data['type'])) $model->where('type', $data['type']);
         if(! empty($data['id'])) $model->whereIn('id', $data['id']);
+        if(! empty($data['crt_id'])) $model->whereIn('crt_id', $data['crt_id']);
         if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
             $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
             $model->where('crt_time','>=',$return[0]);
@@ -230,18 +229,8 @@ class CustomerSupplyService extends Service
         if(empty($data['type'])) return [false, '人员类型不能为空'];
         if(! isset(CustomerSupply::$type_name[$data['type']])) return [false, '人员类型错误'];
         if(! empty($data['status']) && ! isset(CustomerSupply::$status_name[$data['status']])) return [false, '合作状态错误'];
-
-        if(! empty($data['organization'])){
-            $ids = array_column($data['organization'], 'organization_id');
-            // 检查空值
-            if (in_array('', $ids, true) || in_array(null, $ids, true)) {
-                return [false, '组织不能为空'];
-            }
-            // 检查重复
-            if (count($ids) !== count(array_unique($ids))) {
-                return [false, '组织不能重复'];
-            }
-        }
+        list($status, $msg) = $this->checkArrayRepeat($data['organization'],'organization_id','组织');
+        if(! $status) return [false, $msg];
 
         if($is_add){
             $bool = CustomerSupply::where('code',$data['code'])
@@ -274,4 +263,13 @@ class CustomerSupplyService extends Service
 
         return $data;
     }
+
+    public function getEmployeeMap($employee_ids){
+        if(empty($employee_ids)) return [];
+        if(! is_array($employee_ids)) $employee_ids = [$employee_ids];
+
+        return CustomerSupply::whereIn('id', $employee_ids)
+            ->pluck('title', 'id')
+            ->toArray();
+    }
 }

+ 5 - 18
app/Service/EmployeeService.php

@@ -211,7 +211,7 @@ class EmployeeService extends Service
             return [false, $exception->getMessage()];
         }
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     public function employeeDetail($data, $user){
@@ -629,7 +629,7 @@ class EmployeeService extends Service
             'del_time'=>time()
         ]);
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     /**
@@ -818,7 +818,7 @@ class EmployeeService extends Service
             'del_time'=>time()
         ]);
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     /**
@@ -1014,10 +1014,10 @@ class EmployeeService extends Service
     public static function checkUser($userId){
         $res = Employee::where('id', $userId)
             ->where('del_time',0)
-            ->where('is_admin',Employee::IS_ADMIN)
             ->first();
-        if(empty($res)) return [false, '账号限制登录PC端后台'];
+        if(empty($res)) return [false, '账号不存在或已被删除'];
         $res = $res->toArray();
+        if($res['is_admin'] == Employee::IS_NOT_ADMIN) return [false, '账号限制登录PC端后台'];
 
         return [true, $res];
     }
@@ -1317,17 +1317,4 @@ class EmployeeService extends Service
 
         return [true, $res];
     }
-
-    public function getTopMessage($data,$user){
-        $top = $user['depart_top'] ?? [];
-        return [true, ['top' => $top]];
-    }
-
-    public function searchByEmpName($emp_name){
-        $emp = Employee::where('del_time',0)
-            ->where('emp_name', 'LIKE', '%'.$emp_name.'%')
-            ->select('id')
-            ->get()->toArray();
-        return array_column($emp,'id');
-    }
 }

+ 1 - 1
app/Service/HeaderWord/HeaderWordHookService.php

@@ -104,7 +104,7 @@ class HeaderWordHookService extends Service
     public function del($data){
         if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     public function detail($data){

+ 208 - 154
app/Service/ImportService.php

@@ -4,7 +4,10 @@ namespace App\Service;
 
 use App\Exports\TableHeadExport;
 use App\Import\ImportAll;
+use App\Model\CustomerSupply;
 use App\Model\Employee;
+use App\Model\Order;
+use App\Model\OrderDetails;
 use App\Model\Organization;
 use App\Model\GiveOut;
 use App\Model\Product;
@@ -17,9 +20,7 @@ use PhpOffice\PhpSpreadsheet\Shared\Date;
 class ImportService extends Service
 {
     public static $type = [
-        'product', //存货
-        'freight', //运费设置
-        'giveOut', //发放统计
+        'order', //订单
     ];
 
     public function getTableTitleXls($data,$user){
@@ -45,36 +46,16 @@ class ImportService extends Service
         if(empty($type)) return [];
 
         //获取配置文件
-        $config = "excel." . $type . "Table";
+        $config = "excel." . $type;
         return config($config) ?? [];
     }
 
-    private function product($data,$user){
+    private function order($data,$user){
         $config_array = $this->getTableConfig($data['type']);
         if(empty($config_array)) return [false, ['导入配置表头文件不存在','']];
 
         //生成下载文件
-        $filename =  "存货导入模板_" . time() . '.' . 'xlsx';
-
-        return [true, [$config_array, $filename]];
-    }
-
-    private function freight($data,$user){
-        $config_array = $this->getTableConfig($data['type']);
-        if(empty($config_array)) return [false, ['导入配置表头文件不存在','']];
-
-        //生成下载文件
-        $filename =  "运费设置导入模板_" . time() . '.' . 'xlsx';
-
-        return [true, [$config_array, $filename]];
-    }
-
-    private function giveOut($data,$user){
-        $config_array = $this->getTableConfig($data['type']);
-        if(empty($config_array)) return [false, ['导入配置表头文件不存在','']];
-
-        //生成下载文件
-        $filename =  "发放统计导入模板_" . time() . '.' . 'xlsx';
+        $filename =  "订单导入模板_" . time() . '.' . 'xlsx';
 
         return [true, [$config_array, $filename]];
     }
@@ -131,7 +112,7 @@ class ImportService extends Service
         return [true, ''];
     }
 
-    public function productImport($array, $user, $other_param){
+    public function orderImport($array, $user, $other_param){
         $upload = $array[0];
         list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
         if(! $status) return [false, $msg];
@@ -145,48 +126,77 @@ class ImportService extends Service
         if(! empty($error)) return [0, $error];
         if(empty($array)) return [false, '导入数据不能为空'];
 
-        //查找产品
-        $product_map = Product::whereIn("code", array_column($array,0))
-            ->where('del_time',0)
-            ->pluck('id','code')
-            ->toArray();
+        list($error, $map, $total_map) = $this->orderCheck($array, $user);
+        if(! empty($error)) return [0, $error];
+        $order_map = $this->getOrder($array, $user);
 
         $time = time();
-        $insert = $update = [];
-        foreach ($array as $value){
-            $tmp = [];
+        $insert = $update = $detail = $order_number = [];
+        foreach ($array as $key => $value){
+            $main_tmp = $detail_tmp = [];
             foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
+                $t = $table_config[$k];
+                $field = $t['key'];
+                if(! empty($t['is_main'])){
+                    $main_tmp[$field] = $val;
+                }
+                if(! empty($t['is_detail'])){
+                    $detail_tmp[$field] = $val;
+                }
             }
 
-            if(isset($product_map[$tmp['code']])){
-                $product_id = $product_map[$tmp['code']];
-                //产品主表
-                $update[$product_id] = $tmp;
+            $main_tmp['customer_id'] = $map[$key]['customer_id'] ?? 0;
+            $main_tmp['supply_id'] = $map[$key]['supply_id'] ?? 0;
+            $main_tmp['quantity'] = $total_map[$main_tmp['order_number']] ?? 0;
+            if(isset($order_map[$main_tmp['order_number']])){
+                $order_id = $order_map[$main_tmp['order_number']];
+                //更新
+                $update[$order_id] = $main_tmp;
             }else{
-                $tmp['crt_id'] = $user['id'];
-                $tmp['crt_time'] = $time;
+                $main_tmp['crt_id'] = $user['id'];
+                $main_tmp['crt_time'] = $time;
 
-                //产品主表
-                $insert[$tmp['code']] = $tmp;
+                //新增
+                $insert[$main_tmp['order_number']] = $main_tmp;
             }
+
+            $detail_tmp['order_number'] = $main_tmp['order_number'];
+            $detail_tmp['crt_time'] = $time;
+            $detail[] = $detail_tmp;
+
+            $order_number[] = $main_tmp['order_number'];
         }
 
         try{
             //新增
             if(! empty($insert)){
-                Product::insert($insert);
+                Order::insert($insert);
             }
 
             //编辑
             if(! empty($update)){
                 foreach ($update as $p_id => $value){
-                    Product::where('id',$p_id)
+                    Order::where('id',$p_id)
                         ->update($value);
                 }
             }
 
+            if(! empty($detail)){
+                $maps = Order::where('del_time',0)
+                    ->whereIn('order_number',$order_number)
+                    ->pluck('id','order_number')
+                    ->toArray();
+                foreach ($detail as $key => $value){
+                    $detail[$key]['order_id'] = $maps[$value['order_number']] ?? 0;
+                    unset($detail[$key]['order_number']);
+                }
+                OrderDetails::where('del_time',0)
+                    ->where('order_id',array_values($maps))
+                    ->update(['del_time' => $time]);
+
+                OrderDetails::insert($detail);
+            }
+
             DB::commit();
         }catch (\Exception $e){
             DB::rollBack();
@@ -196,137 +206,181 @@ class ImportService extends Service
         return [true, ''];
     }
 
-    public function freightImport($array, $user, $other_param){
-        $upload = $array[0];
-        list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
-        if(! $status) return [false, $msg];
-        $table_config = $msg;
+    private function getCustomerSupply($array, $user){
+        //查找客户 供应商
+        $customer_codes = array_unique(array_filter(array_column($array,1)));
+        $customer_titles = array_unique(array_filter(array_column($array,2)));
+        $supply_codes = array_unique(array_filter(array_column($array,3)));
+        $supply_titles = array_unique(array_filter(array_column($array,4)));
+        $records = CustomerSupply::where('del_time', 0)
+            ->where('crt_id', $user['id'])
+            ->where(function($query) use ($customer_codes, $customer_titles, $supply_codes, $supply_titles) {
+                $query->where(function($q) use ($customer_codes, $customer_titles) {
+                    $q->where('type', CustomerSupply::type_one)
+                        ->where(function($sub) use ($customer_codes, $customer_titles) {
+                            $sub->whereIn('code', $customer_codes)
+                                ->orWhereIn('title', $customer_titles);
+                        });
+                })->orWhere(function($q) use ($supply_codes, $supply_titles) {
+                    $q->where('type', CustomerSupply::type_two)
+                        ->where(function($sub) use ($supply_codes, $supply_titles) {
+                            $sub->whereIn('code', $supply_codes)
+                                ->orWhereIn('title', $supply_titles);
+                        });
+                });
+            })
+            ->select('id','title','code','type')
+            ->get()
+            ->toArray();
 
-        // 去除表头
-        unset($array[0]);
-        if(empty($array)) return [false, '导入数据不能为空'];
+        return $records;
+    }
 
-        list($array, $error) = $this->checkCommon($array, $table_config);
-        if(! empty($error)) return [0, $error];
-        if(empty($array)) return [false, '导入数据不能为空'];
+    private function getOrder($array, $user){
+        $order = array_unique(array_filter(array_column($array,0)));
+        $records = Order::where('del_time', 0)
+            ->where('crt_id', $user['id'])
+            ->whereIn('order_number', $order)
+            ->pluck('id','order_number')
+            ->toArray();
 
-        $time = time();
-        $insert = [];
-        foreach ($array as $value){
-            $tmp = [];
-            foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
-            }
+        return $records;
+    }
 
-            $tmp['crt_id'] = $user['id'];
-            $tmp['crt_time'] = $time;
+    private function orderCheck(&$array, $user)
+    {
+        // 查询所有客户 / 供应商档案
+        $customer_supply = $this->getCustomerSupply($array, $user);
 
-            $insert[] = $tmp;
+        // 建立映射表(code、title 都可以匹配到记录)
+        $map_by_code  = array_column($customer_supply, null, 'code');
+        $map_by_title = [];
+        foreach ($customer_supply as $value){
+            $map_by_title[$value['title']][] = $value;
         }
 
-        try{
-            Organization::where('del_time',0)
-                ->update(['del_time' => $time]);
-            //新增
-            if(! empty($insert)) Organization::insert($insert);
+        $errors = []; // 存放错误信息
+        $success = []; // 存放校验通过的行
 
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            return [false, $e->getMessage() . $e->getLine() . $e->getCode()];
-        }
+        $order_material_map = [];
+        $order_total_map = [];    // 统计每个订单号的总数量
+        foreach ($array as $rowIndex => $value) {
+            $rowNum = $rowIndex; // 行号
 
-        return [true, ''];
-    }
+            if(! empty($value[5])){
+                list($status, $msg) = $this->convertExcelCellToDate($value[5]);
+                if(! $status){
+                    $error_2[] = "第" . $rowNum ."行" . "的订单日期错误";
+                }else{
+                    $array[$rowIndex][5] = $msg;
+                }
+            }
 
-    public function giveOutImport($array, $user, $other_param){
-        $upload = $array[0];
-        list($status, $msg) = $this->compareTableAndReturn($upload, $other_param);
-        if(! $status) return [false, $msg];
-        $table_config = $msg;
+            // -------- 客户校验 --------
+            $customer_id = 0;
+            if (!empty($value[1]) || !empty($value[2])) {
+                $customer_id = $this->checkData($value, $rowNum,'客户',CustomerSupply::type_one, $errors,$map_by_code,$map_by_title);
+            }
 
-        // 去除表头
-        unset($array[0]);
-        if(empty($array)) return [false, '导入数据不能为空'];
+            // -------- 供应商校验 --------
+            $supply_id = 0;
+            if (!empty($value[3]) || !empty($value[4])) {
+                $supply_id = $this->checkData($value, $rowNum,'供应商',CustomerSupply::type_two, $errors,$map_by_code,$map_by_title);
+            }
 
-        list($array, $error) = $this->checkCommon($array, $table_config);
-        if(! empty($error)) return [0, $error];
-        if(empty($array)) return [false, '导入数据不能为空'];
+            $success[$rowNum] = [
+                'customer_id' => $customer_id,
+                'supply_id'   => $supply_id,
+            ];
+
+            // -------- 新增:校验订单号 + 物料编码 不重复 --------
+            $order_no = trim($value[0] ?? '');
+            $material_code = trim($value[6] ?? '');
+
+            if ($order_no !== '' && $material_code !== '') {
+                // 组合唯一 key
+                $unique_key = $order_no . '|' . $material_code;
+
+                if (isset($order_material_map[$unique_key])) {
+                    // 已经存在重复
+                    $firstRow = $order_material_map[$unique_key];
+                    $errors[] = "第{$rowNum}行:订单号 {$order_no} 下的物料编码 {$material_code} 重复(首次出现在第 {$firstRow} 行)";
+                } else {
+                    // 记录首次出现的行号
+                    $order_material_map[$unique_key] = $rowNum;
+                }
+            }
+
+            $qty = $value[10];
+            if ($order_no !== '') {
+                if (isset($order_total_map[$order_no])) {
+                    $tmp_num = bcadd($qty, $order_total_map[$order_no],2);
+                    $order_total_map[$order_no] = $tmp_num;
+                }else{
+                    $order_total_map[$order_no] = $qty;
+                }
 
-        $time = time();
-        $new_array = [];
-        foreach ($array as $value){
-            $tmp = [];
-            foreach ($value as $k => $val){
-                $field = $table_config[$k]['key'];
-                $tmp[$field] = $val;
             }
-            $tmp['crt_id'] = $user['id'];
-            $tmp['crt_time'] = $time;
+        }
 
-            $new_array[] = $tmp;
+        $error_string = "";
+        if(! empty($errors)) $error_string = implode('|', $errors);
+
+        return [
+            $error_string ,
+            $success,
+            $order_total_map
+        ];
+    }
+
+    private function checkData($value, $rowNum, $main_title, $type,&$errors,$map_by_code,$map_by_title){
+        $customer_id_1 = $customer_id_2 = 0;
+        if($type == CustomerSupply::type_one){
+            $code  = $value[1] ?? '';
+            $title = $value[2] ?? '';
+        }else{
+            $code  = $value[3] ?? '';
+            $title = $value[4] ?? '';
         }
-        $emp_map = Employee::where('del_time',0)
-            ->whereIn('emp_name', array_column($new_array,'employee_id_1_title'))
-            ->pluck('id','emp_name')
-            ->toArray();
 
-        $error_2 = [];
-        foreach ($new_array as $key => $value){
-            $line_number = $key + 2;
-            $line = '第' . $line_number . '行';
-            if(! isset($emp_map[$value['employee_id_1_title']])) {
-                $error_2[] = $line . "业务员不存在或已被删除";
-            }else{
-                $new_array[$key]['employee_id_1'] = $emp_map[$value['employee_id_1_title']];
-            }
-            list($status, $msg) = $this->convertExcelCellToDate($value['send_time']);
-            if(! $status){
-                $error_2[] = $line . "发放日期错误";
-            }else{
-                $new_array[$key]['send_time'] = $msg;
+        $match_code = $map_by_code[$code] ?? null;
+        $match_title = $map_by_title[$title] ?? null;
+        if($code){
+            if(empty($match_code) || $match_code['type'] != $type){
+                $errors[] = "第{$rowNum}行:{$main_title}编码({$code}) 未在档案中找到";
+            }else {
+                $customer_id_1 = $match_code['id'];
             }
-            if (strpos($value['belong_time'], '|') !== false) {
-                list($start,$end) = explode('|', $value['belong_time']);
-                $startStamp = strtotime($start);
-                $endStamp = strtotime($end);
-                if(! $startStamp || ! $endStamp || $startStamp > $endStamp) {
-                    $error_2[] = $line . "归属日期错误";
-                }else{
-                    $new_array[$key]['start_time'] = $startStamp;
-                    $new_array[$key]['end_time'] = $endStamp;
-                    unset($new_array[$key]['belong_time']);
-                }
-            }else{
-                list($status, $msg) = $this->convertExcelCellToDate($value['belong_time']);
-                if(! $status){
-                    $error_2[] = $line . "归属日期错误";
+        }
+        if($title){
+            if(empty($match_title)){
+                $errors[] = "第{$rowNum}行:{$main_title}名称({$title}) 未在档案中找到";
+            }elseif (count($match_title) > 1){
+                if(empty($code)){
+                    $errors[] = "第{$rowNum}行:{$main_title}名称({$title}) 在档案中找到多条数据,请填写客户编码";
                 }else{
-                    $new_array[$key]['start_time'] = $msg;
-                    $new_array[$key]['end_time'] = $msg;
-                    unset($new_array[$key]['belong_time']);
+                    $tmp = array_column($match_title,null,'code');
+                    if(isset($tmp[$code])){
+                        $t = $tmp[$code];
+                        if($t['type'] != $type) {
+                            $errors[] = "第{$rowNum}行:{$main_title}名称({$title}) 未在档案中找到";
+                        }else{
+                            $customer_id_2 = $t['id'];
+                        }
+                    }else{
+                        $errors[] = "第{$rowNum}行:{$main_title}编码和名称对应数据未在档案中找到";
+                    }
                 }
+            }else {
+                $tt = $match_title[0] ?? [];
+                $customer_id_2 = $tt['id'] ?? 0;
             }
-            $res = $this->checkNumber($value['give_out_amount'],2,'positive');
-            if(! $res['valid']) $error_2[] = $line . "分红已发放金额:" . $res['error'];
-        }
-        if(! empty($error_2)) {
-            $error_string = implode('|', $error_2);
-            return [0, $error_string];
         }
+        if($customer_id_1 && $customer_id_2 && $customer_id_1 != $customer_id_2) $errors[] = "第{$rowNum}行:{$main_title}编码和名称对应数据未在档案中找到";
 
-        try{
-            //新增
-            if(! empty($new_array)) GiveOut::insert($new_array);
-
-            DB::commit();
-        }catch (\Exception $e){
-            DB::rollBack();
-            return [false, $e->getMessage() . $e->getLine() . $e->getCode()];
-        }
+        $customer_id = $customer_id_1 ? $customer_id_1 : $customer_id_2;
 
-        return [true, ''];
+        return $customer_id;
     }
 
     //公共校验

+ 1 - 1
app/Service/Oa/OaService.php

@@ -158,7 +158,7 @@ class OaService extends Service
             'del_time' => time(),
         ]);
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     public function oaSubType($data){

+ 1 - 1
app/Service/OaService.php

@@ -386,7 +386,7 @@ class OaService extends Service
             'del_time' => time(),
         ]);
 
-        return [true, '删除成功'];
+        return [true, ''];
     }
 
     public function oaSubType($data)

+ 240 - 0
app/Service/OrderService.php

@@ -0,0 +1,240 @@
+<?php
+
+namespace App\Service;
+
+use App\Model\Employee;
+use App\Model\Order;
+use App\Model\OrderDetails;
+use Illuminate\Support\Facades\DB;
+
+class OrderService extends Service
+{
+    public function orderEdit($data,$user){
+        list($status,$msg) = $this->orderRule($data, $user, false);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = Order::where('id',$data['id'])->first();
+            $model->order_number = $data['order_number'] ?? '';
+            $model->customer_id = $data['customer_id'] ?? 0;
+            $model->supply_id = $data['supply_id'] ?? 0;
+            $model->order_time = $data['order_time'] ?? 0;
+            $model->quantity = $data['quantity'] ?? 0;
+            $model->save();
+
+            $time = time();
+            OrderDetails::where('del_time',0)
+                ->where('order_id', $model->id)
+                ->update(['del_time' => $time]);
+            $this->saveDetail($model->id, $time, $data);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    public function orderAdd($data,$user){
+        list($status,$msg) = $this->orderRule($data, $user);
+        if(!$status) return [$status,$msg];
+
+        try {
+            DB::beginTransaction();
+
+            $model = new Order();
+            $model->order_number = $data['order_number'] ?? '';
+            $model->customer_id = $data['customer_id'] ?? 0;
+            $model->supply_id = $data['supply_id'] ?? 0;
+            $model->order_time = $data['order_time'] ?? 0;
+            $model->quantity = $data['quantity'] ?? 0;
+            $model->crt_id = $user['id'];
+            $model->save();
+            
+            $this->saveDetail($model->id, time(), $data);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    private function saveDetail($id, $time, $data){
+        if(! empty($data['details'])){
+            $unit = [];
+            foreach ($data['details'] as $value){
+                $unit[] = [
+                    'order_id' => $id,
+                    'code' => $value['code'],
+                    'title' => $value['title'],
+                    'size' => $value['size'] ?? "",
+                    'unit' => $value['unit'] ?? "",
+                    'quantity' => $value['quantity'],
+                    'crt_time' => $time,
+                ];
+            }
+            if(! empty($unit)) OrderDetails::insert($unit);
+        }
+    }
+
+    private function getDetail($id){
+        $data = OrderDetails::where('del_time',0)
+            ->where('order_id', $id)
+            ->get()->toArray();
+
+        $unit = [];
+        foreach ($data as $value){
+            $unit[] = [
+                'code' => $value['code'],
+                'title' => $value['title'],
+                'size' => $value['size'],
+                'unit' => $value['unit'],
+                'quantity' => $value['quantity'],
+            ];
+        }
+
+        $detail = [
+            'details' => $unit,
+        ];
+
+        foreach ($detail as $key => $value) {
+            if (empty($value)) {
+                $detail[$key] = (object)[]; // 转成 stdClass 对象
+            }
+        }
+
+        return $detail;
+    }
+
+    public function orderDel($data){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+
+        try {
+            DB::beginTransaction();
+            $time = time();
+
+            Order::where('del_time',0)
+                ->whereIn('id',$data['id'])
+                ->update(['del_time' => $time]);
+
+            OrderDetails::where('del_time',0)
+                ->where('order_id', $data['id'])
+                ->update(['del_time' => $time]);
+
+            DB::commit();
+        }catch (\Exception $exception){
+            DB::rollBack();
+            return [false,$exception->getMessage()];
+        }
+
+        return [true, ''];
+    }
+
+    public function orderDetail($data, $user){
+        if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
+        $customer = Order::where('del_time',0)
+            ->where('id',$data['id'])
+            ->first();
+        if(empty($customer)) return [false,'订单不存在或已被删除'];
+        $customer = $customer->toArray();
+        $customer['crt_name'] = Employee::where('id',$customer['crt_id'])->value('emp_name');
+        $customer['crt_time'] = $customer['crt_time'] ? date("Y-m-d H:i:s",$customer['crt_time']): '';
+
+        $details = $this->getDetail($data['id']);
+        $customer = array_merge($customer, $details);
+
+        return [true, $customer];
+    }
+
+    public function orderCommon($data,$user, $field = []){
+        if(empty($field)) $field = Order::$field;
+
+        $model = Order::Clear($user,$data);
+        $model = $model->where('del_time',0)
+            ->select($field)
+            ->orderby('id', 'desc');
+
+        if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
+        if(! empty($data['order_number'])) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
+        if(! empty($data['id'])) $model->whereIn('id', $data['id']);
+        if(! empty($data['crt_time'][0]) && ! empty($data['crt_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['crt_time']);
+            $model->where('crt_time','>=',$return[0]);
+            $model->where('crt_time','<=',$return[1]);
+        }
+        if(! empty($data['order_time'][0]) && ! empty($data['order_time'][1])) {
+            $return = $this->changeDateToTimeStampAboutRange($data['order_time']);
+            $model->where('order_time','>=',$return[0]);
+            $model->where('order_time','<=',$return[1]);
+        }
+
+        return $model;
+    }
+
+    public function orderList($data,$user){
+        $model = $this->orderCommon($data, $user);
+        $list = $this->limit($model,'',$data);
+        $list = $this->fillData($list,$user,$data);
+
+        $list['count'] = $this->countTotal($list['data'], $user['header_default']);
+
+        return [true, $list];
+    }
+
+    public function orderRule(&$data, $user, $is_add = true){
+        if(empty($data['order_number'])) return [false, '订单号不能为空'];
+        if(empty($data['details'])) return [false, '物料不能为空'];
+        $total = 0;
+        foreach ($data['details'] as $value){
+            if(empty($value['code'])) return [false, '物料编码不能为空'];
+            if(empty($value['title'])) return [false, '物料名称不能为空'];
+            $res = $this->checkNumber($data['quantity'],2,'positive');
+            if(! $res['valid']) return [false,'物料数量:' . $res['error']];
+            $total = bcadd($total, $value['quantity'],2);
+        }
+        $data['quantity'] = $total;
+        list($status, $msg) = $this->checkArrayRepeat($data['details'],'code','物料编码');
+        if(! $status) return [false, $msg];
+        if(! empty($data['order_time'])) $data['order_time'] = $this->changeDateToDate($data['order_time']);
+
+        if($is_add){
+            $bool = Order::where('order_number',$data['order_number'])
+                ->where('crt_id', $user['id'])
+                ->where('del_time',0)
+                ->exists();
+        }else{
+            if(empty($data['id'])) return [false,'ID不能为空'];
+            $bool = Order::where('order_number',$data['order_number'])
+                ->where('crt_id', $user['id'])
+                ->where('id','<>',$data['id'])
+                ->where('del_time',0)
+                ->exists();
+        }
+        if($bool) return [false, '订单号已存在'];
+
+        return [true, $data];
+    }
+
+    public function fillData($data, $user, $search){
+        if(empty($data['data'])) return $data;
+
+        $emp = (new EmployeeService())->getEmployeeMap(array_unique(array_column($data['data'],'id')));
+        $emp_2 = (new CustomerSupplyService())->getEmployeeMap(array_unique(array_merge_recursive(array_column($data['data'],'customer_id'), array_column($data['data'],'supply_id'))));
+        foreach ($data['data'] as $key => $value){
+            $data['data'][$key]['crt_time'] = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
+            $data['data'][$key]['order_time'] = $value['order_time'] ? date('Y-m-d',$value['order_time']) : '';
+            $data['data'][$key]['crt_name'] = $emp[$value['crt_id']] ?? '';
+            $data['data'][$key]['customer_title'] = $emp_2[$value['customer_id']] ?? '';
+            $data['data'][$key]['supply_title'] = $emp_2[$value['supply_id']] ?? '';
+        }
+
+        return $data;
+    }
+}

+ 15 - 0
app/Service/Service.php

@@ -929,4 +929,19 @@ class Service
         $result = array_pop($stack) ?? '0';
         return bcadd($result, '0', $decimals);
     }
+
+    public function checkArrayRepeat($data, $column, $title = ""){
+        $ids = array_column($data[$column], $column);
+
+        // 检查空值
+        if (in_array('', $ids, true) || in_array(null, $ids, true)) {
+            return [false, $title . '不能为空'];
+        }
+        // 检查重复
+        if (count($ids) !== count(array_unique($ids))) {
+            return [false, $title . '不能重复'];
+        }
+
+        return [true, ''];
+    }
 }

+ 1 - 1
app/Service/SysMenuService.php

@@ -129,7 +129,7 @@ class SysMenuService extends Service
             return [false,$exception->getMessage()];
         }
 
-        return [true,'删除成功'];
+        return [true,''];
     }
 
     public function menuList($data,$user){

+ 14 - 14
app/Service/Weixin/WeixinService.php

@@ -12,10 +12,10 @@ class WeixinService extends Service
     const ACCESS_URL = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s';
     const OPENID = '';
     const TOKEN = '';
-    const KEY = 'weixintnine';
+    const KEY = 'weixinsupplymarketing';
 
     const STABLE_TOKEN_URL = 'https://api.weixin.qq.com/cgi-bin/stable_token'; // 稳定版接口
-    const KEY_STABLE = 'weixinMessage';
+    const KEY_STABLE = 'weixinsupplymarketing';
 
     public function getToken(){
         $token_key = self::KEY.'_'.'token';
@@ -65,18 +65,6 @@ class WeixinService extends Service
         return [true, $token];
     }
 
-    public function getOpenid($data){
-        if(empty($data['code'])) return [false, 'code不能为空'];
-        $code = $data['code'];
-        $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code';
-        $url = sprintf($url,self::APPID,self::APPSECRET,$code);
-        $res = $this->curlOpen($url);
-        $res = json_decode($res,true);
-        if(!isset($res['openid'])) return [false,$res['errmsg']??'request error'];
-        $openid = $res['openid'];
-        return [true,['openid' => $openid]];
-    }
-
     public function setWebHook($data){
 //        file_put_contents('22.txt',json_encode($data));
         $uri = isset($data['uri']) ? $data['uri'] : '';
@@ -104,6 +92,18 @@ class WeixinService extends Service
         }
     }
 
+    public function getOpenid($data){
+        if(empty($data['code'])) return [false, 'code不能为空'];
+        $code = $data['code'];
+        $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code';
+        $url = sprintf($url,self::APPID,self::APPSECRET,$code);
+        $res = $this->curlOpen($url);
+        $res = json_decode($res,true);
+        if(!isset($res['openid'])) return [false,$res['errmsg']??'request error'];
+        $openid = $res['openid'];
+        return [true,['openid' => $openid]];
+    }
+
 //    public function sendTmpMsg($data){
 //        //        $openid = 'okXNa69ggEX61KvHUhCq9PcGrPKI';
 //        $data = [

+ 1 - 94
app/Service/Wx/WxEmployeeService.php

@@ -3,24 +3,10 @@
 namespace App\Service\Wx;
 
 use App\Model\Employee;
-use App\Model\EmployeeDepartPermission;
-use App\Model\EmployeeFoursShop;
-use App\Model\EmployeeTeamPermission;
-use App\Model\FoursShop;
-use App\Model\StorehouseEmployee;
-use App\Model\TemporaryJs;
 use App\Model\WxEmployee;
-use App\Service\EmployeeService;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Hash;
 
-/**
- * 区域相关
- * @package App\Models
- */
 class WxEmployeeService extends Service
 {
-
     public function setUser($data){
         if(empty($data['code'])) return [false, '用户登录凭证(code)不能为空'];
         $code = $data['code'];
@@ -53,7 +39,6 @@ class WxEmployeeService extends Service
         return [true,['openid'=>$openid, 'state'=> $state]];
     }
 
-
     public function setMobile($data){
         if(empty($data['code'])) return [false, '用户登录凭证(code)不能为空'];
         if(empty($data['openid'])) return [false, 'openID不能为空'];
@@ -64,89 +49,11 @@ class WxEmployeeService extends Service
         if(!$status) return [false,$mobile];
 
         $user = WxEmployee::where('openid',$openid)->first();
-        if(empty($user))  return [false,'openID在系统中暂无记录'];
+        if(empty($user)) return [false,'openID在系统中暂无记录'];
 
         $user->mobile = $mobile;
         $user->save();
 
         return [true, ['mobile' => $mobile]];
     }
-
-    public function login($data){
-        if(empty($data['account'])) return [false, '账号不能为空'];
-        if(empty($data['password'])) return [false, '密码不能为空'];
-        if(empty($data['openid'])) return [false, 'openID不能为空'];
-        $account = $data['account'];
-        $password = $data['password'];
-        $openid = $data['openid'];
-
-        list($status,$data) = $this->loginRule([
-            'account' => $account,
-            'password' => $password,
-        ]);
-
-        if(!$status) return [false,$data];
-        $user_id = $data['id'];
-        $user = WxEmployee::where('openid',$openid)->first();
-        if(empty($user)||empty($user->mobile)) return [false,'请先登陆'];
-
-        $user->employee_id = $user_id;
-        $user->save();
-
-        return [true,$data];
-    }
-
-    public function loginRule($data){
-        if($this->isEmpty($data,'account')) return [false,'账号不能为空!'];
-        if($this->isEmpty($data,'password')) return [false,'密码不存在!'];
-
-        $account = $data['account'];
-        $res = Employee::where('del_time',0)
-            ->where(function ($query)use($account) {
-                $query->where('account', $account)
-                    ->orWhere('mobile', $account);
-            })
-            ->get()->toArray();
-
-        if(empty($res)) return [false,'账号不存在或已被删除!'];
-        if(count($res) > 1) return [false,'手机号绑定多个账户!'];
-
-        $res = reset($res);
-        if(! Hash::check($data['password'], $res['password'])) return [false,'密码错误!'];
-        if($res['state'] == Employee::NOT_USE) return [false,'账号停用!'];
-
-        return [true, ['id'=>$res['id'], 'name'=>$res['emp_name'], 'account' => $res['account']]];
-    }
-
-    public function checkWxUser($userId){
-        $res = Employee::where('id', $userId)
-//            ->where('del_time',0)
-            ->where('state',Employee::USE)->get()->first();
-        if(empty($res)) return [false, '该账号无法登录,请联系管理员!'];
-
-        return [true, $res];
-    }
-
-    public function getTopMessage($data){
-        if($this->isEmpty($data,'openid')) return [false,'openid不能为空!'];
-
-        $employee = WxEmployee::where('openid',$data['openid'])->first();
-        if(empty($employee)) return [false,'未找到用户信息!'];
-        $employee = $employee->toArray();
-        if(empty($employee['employee_id'])) {
-            //找到对应的账号
-            $emp = Employee::where('del_time',0)
-                ->where('mobile',$employee['mobile'])
-                ->where('state',Employee::USE)
-                ->select('id')
-                ->first();
-            if(empty($emp)) return [0,'用户手机信息未匹配到系统账号,请录入手机号!'];
-            $emp = $emp->toArray();
-            WxEmployee::where('id',$employee['id'])->update(['employee_id' => $emp['id']]);
-            $employee['employee_id'] = $emp['id'];
-        }
-        $return = EmployeeService::getLoginMessage($employee['employee_id']);
-
-        return [true, $return];
-    }
 }

+ 0 - 43
config/excel/freightTable.php

@@ -1,43 +0,0 @@
-<?php
-return [
-    [
-        'key' =>'area',
-        'value' => '所属区域',
-        'required' => true,
-    ],
-    [
-        'key' =>'region',
-        'value' => '地区',
-        'required' => true,
-    ],
-    [
-        'key' =>'kilometer',
-        'value' => '公里数',
-        'required' => true,
-        'default' => 0,
-    ],
-    [
-        'key' =>'min_freight_fee',
-        'value' => '最低运费',
-        'required' => true,
-        'default' => 0,
-    ],
-    [
-        'key' =>'one_and_five',
-        'value' => '1-5吨',
-        'required' => true,
-        'default' => 0,
-    ],
-    [
-        'key' =>'greater_than_five',
-        'value' => '5吨以上',
-        'required' => true,
-        'default' => 0,
-    ],
-    [
-        'key' =>'company',
-        'value' => '物流公司',
-        'required' => false,
-        'default' => '',
-    ],
-];

+ 75 - 0
config/excel/order.php

@@ -0,0 +1,75 @@
+<?php
+return [
+    [
+        'key' =>'order_number',
+        'value' => '订单号',
+        'required' => true,
+        'is_main' => true,
+    ],
+    [
+        'key' =>'customer_code',
+        'value' => '客户编码',
+        'required' => false,
+        'default' => "",
+    ],
+    [
+        'key' =>'customer_title',
+        'value' => '客户名称',
+        'required' => false,
+        'default' => "",
+    ],
+    [
+        'key' =>'supply_code',
+        'value' => '供应商编码',
+        'required' => false,
+        'default' => "",
+    ],
+    [
+        'key' =>'supply_title',
+        'value' => '供应商名称',
+        'required' => false,
+        'default' => "",
+    ],
+    [
+        'key' =>'order_time',
+        'value' => '订单日期',
+        'required' => false,
+        'default' => "",
+        'is_main' => true,
+    ],
+    [
+        'key' =>'product_code',
+        'value' => '物料编码',
+        'required' => true,
+        'default' => "",
+        'is_detail' => true,
+    ],
+    [
+        'key' =>'product_title',
+        'value' => '物料名称',
+        'required' => true,
+        'default' => '',
+        'is_detail' => true,
+    ],
+    [
+        'key' =>'size',
+        'value' => '物料规格',
+        'required' => false,
+        'default' => '',
+        'is_detail' => true,
+    ],
+    [
+        'key' =>'unit',
+        'value' => '单位',
+        'required' => false,
+        'default' => '',
+        'is_detail' => true,
+    ],
+    [
+        'key' =>'quantity',
+        'value' => '数量',
+        'required' => true,
+        'default' => 0,
+        'is_detail' => true,
+    ],
+];

+ 14 - 32
config/header/68.php

@@ -7,50 +7,32 @@
 
 return [
     [
-        'key' =>'order_type_title',
-        'value' => '单据类型',
+        'key' =>'order_number',
+        'value' => '订单编码',
     ],
     [
-        'key' =>'order_time',
-        'value' => '统计年月',
-    ],
-    [
-        'key' =>'employee_id_1_title',
-        'value' => '业务员',
+        'key' =>'customer_title',
+        'value' => '客户名称',
     ],
     [
-        'key' =>'income',
-        'value' => '收入金额',
-        'value1' => '销货单:含税金额;
-                     销售发票:开票金额;
-                     回款单:回款金额;',
-        'sum' => 1,
+        'key' =>'supply_title',
+        'value' => '供应商名称',
     ],
     [
-        'key' =>'adjust',
-        'value' => '调整金额',
-        'value1' => '金额为负数的合计',
-        'sum' => 1,
+        'key' =>'order_time',
+        'value' => '订单日期',
     ],
     [
-        'key' =>'business',
-        'value' => '业务成本金额',
-        'value1' => '业务成本金额合计',
+        'key' =>'quantity',
+        'value' => '订单数量',
         'sum' => 1,
     ],
     [
-        'key' =>'profit',
-        'value' => '毛利',
-        'value1' => '收入金额 - 业务成本金额',
-        'sum' => 2,
-        'formula' => 'income - business',
+        'key' =>'crt_name',
+        'value' => '创建人',
     ],
     [
-        'key' =>'profit_rate',
-        'value' => '毛利率%',
-        'value1' => '毛利 / 收入金额',
-        'sum' => 2,
-        'formula' => 'profit / income * 100',
-        'split_join' => '%',
+        'key' =>'crt_time',
+        'value' => '创建时间',
     ],
 ];

+ 7 - 0
routes/api.php

@@ -116,6 +116,13 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('quantizationDel', 'Api\QuantizationController@quantizationDel');
     $route->any('quantizationDetail', 'Api\QuantizationController@quantizationDetail');
 
+    //订单
+    $route->any('orderList', 'Api\OrderController@orderList');
+    $route->any('orderEdit', 'Api\OrderController@orderEdit');
+    $route->any('orderAdd', 'Api\OrderController@orderAdd');
+    $route->any('orderDel', 'Api\OrderController@orderDel');
+    $route->any('orderDetail', 'Api\OrderController@orderDetail');
+
     //获取默认表头
     $route->any('getTableHead','Api\TableHeadController@tableHeadGet');
     //设置表头

+ 8 - 5
routes/weixin.php

@@ -11,15 +11,18 @@
 |
 */
 
-Route::any('weixin', 'Api\WeixinController@weixin');
-Route::any('test', 'Api\WeixinController@test');
+//token
+Route::any('wechatH5', 'Api\WeixinController@wechatH5');
+//前端请求这个接口 最后会带着openid 重定向到前端页面
 Route::any('setWebHook', 'Api\WeixinController@setWebHook');
-Route::any('getUnionid', 'Api\WeixinController@getUnionid');
-
-Route::any('getOpenid', 'Api\WeixinController@getOpenid');
+//前端给的openid 保存
 Route::any('wxSetUser', 'Api\WeixinController@setUser');
+//如果没绑定账号 要求绑定
 Route::any('wxLogin', 'Api\WeixinController@login');
 
+//重定向过程中对外开放的接口 用于最后拿到openid
+Route::any('getUnionid', 'Api\WeixinController@getUnionid');
+Route::any('getOpenid', 'Api\WeixinController@getOpenid');
 Route::group(['middleware'=> ['checkWeixin']],function ($route){
 
 });

+ 0 - 2
routes/wx.php

@@ -14,8 +14,6 @@ use Illuminate\Http\Request;
 
 Route::any('wxSetUser', 'Api\WxController@setUser');
 Route::any('wxSetMobile', 'Api\WxController@setMobile');
-Route::any('wxLogin', 'Api\WxController@login');
-Route::any('wxH5', 'Api\WxController@wxH5');
 Route::group(['middleware'=> ['checkWx']],function ($route){
 
 });