Ver código fonte

Merge branch 'version1.5' of wugg/phpstock into master-online

wugg 2 anos atrás
pai
commit
da1e13d48b

+ 16 - 4
app/ExceptionHandle.php

@@ -1,4 +1,5 @@
 <?php
+
 namespace app;
 
 use think\db\exception\DataNotFoundException;
@@ -31,7 +32,7 @@ class ExceptionHandle extends Handle
      * 记录异常信息(包括日志或者其它方式记录)
      *
      * @access public
-     * @param  Throwable $exception
+     * @param Throwable $exception
      * @return void
      */
     public function report(Throwable $exception): void
@@ -44,7 +45,7 @@ class ExceptionHandle extends Handle
      * Render an exception into an HTTP response.
      *
      * @access public
-     * @param \think\Request   $request
+     * @param \think\Request $request
      * @param Throwable $e
      * @return Response
      */
@@ -52,7 +53,18 @@ class ExceptionHandle extends Handle
     {
         // 添加自定义异常处理机制
 
-        // 其他错误交给系统处理
-        return parent::render($request, $e);
+        switch (strtolower(app('http')->getName())) {
+
+            case 'abutment':
+                if ($e instanceof ValidateException) return json_show(1004, $e->getMessage());
+                else return json_show(1005, $e->getMessage());
+                break;
+
+            default:
+                return parent::render($request, $e); // 其他错误交给系统处理
+
+        }
+
+
     }
 }

+ 10 - 2
app/admin/controller/Action.php

@@ -164,8 +164,16 @@ class Action extends BaseController
         $child =Db::name("admin_menu")->where([["pid","<>",0],['status',"=",1],["is_del","=",0]])->select();
         foreach ($child as $k=>$value){
             // $act = PasAction::all(['menuid'=>$value['id'],"status"=>1]);
-            $act =Db::name("action")->alias("a")->leftJoin("action_list l","a.action_code=l.action_code")->field
-            ("a.*,action_name")->where(['a.menuid'=>$value['id'],"a.status"=>1])->select();
+            $act =Db::name("action")
+                ->alias("a")
+                ->leftJoin("action_list l","a.action_code=l.action_code")
+                ->field("a.*,action_name")
+                ->where(['a.menuid'=>$value['id'],"a.status"=>1])
+                ->withAttr('id',function($val){
+                    return (string)$val;
+                })
+                ->select()
+                ->toArray();
             $act_data = Db::name("action_field")->where(['menuid'=>$value['id'],"status"=>1])->select();
             $value['action'] = $act;
             $value['action_data'] = $act_data;

+ 205 - 0
app/admin/controller/ActionProcess.php

@@ -0,0 +1,205 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\admin\model\ProcessWait;
+use think\facade\Db;
+use think\facade\Validate;
+use app\admin\model\ActionProcess as APModel;
+use app\admin\model\Process as PModel;
+
+//流程节点
+class ActionProcess extends Base
+{
+
+    //获取流程节点列表
+    public function getList()
+    {
+
+        $param = $this->request->filter('trim')->only(['process_id', 'action_type' => '', 'operation_type' => '', 'page' => 1, 'size' => 15], 'post');
+
+        $val = Validate::rule([
+            'process_id|流程id' => 'require|number|gt:0',
+            'page|页码' => 'require|number|gt:0',
+            'size|每页显示的页码' => 'require|number|gt:0',
+        ]);
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        $where = [['is_del', '=', APModel::$is_del_normal]];
+        if ($param['process_id'] != '') $where[] = ['process_id', '=', $param['process_id']];
+        if ($param['action_type'] != '') $where[] = ['action_type', '=', $param['action_type']];
+        if ($param['operation_type'] != '') $where[] = ['operation_type', '=', $param['operation_type']];
+
+        $count = Db::name('action_process')
+            ->where($where)
+            ->count('id');
+
+        $list = APModel::field('id,status_name,order_process,status,action_type,operation_type,next_action_ids,creater,addtime,remark')
+            ->where($where)
+            ->order('id', 'desc')
+            ->page($param['page'], $param['size'])
+            ->select()
+            ->toArray();
+
+        $all_next_ids = implode(',', array_column($list, 'next_action_ids'));
+
+        //处理下一个节点的名称
+        $child = Db::name('action_process')
+            ->whereIn('id', $all_next_ids)
+            ->column('status_name', 'id');
+
+        foreach ($list as &$item) {
+            if ($item['next_action_ids']) {
+                $next_action_ids = explode(',', $item['next_action_ids']);
+                foreach ($next_action_ids as $next_action_id) {
+                    if (isset($child[$next_action_id])) $item['next_actions'][] = $child[$next_action_id];
+                }
+            } else $item['next_actions'] = [];
+        }
+
+        return app_show(0, '获取成功', ['count' => $count, 'list' => $list]);
+
+    }
+
+    //新增
+    public function add()
+    {
+
+        $param = $this->request->filter('trim')->only(['token', 'process_id', 'action_type', 'operation_type', 'status_name', 'order_process', 'next_action_ids' => '', 'remark' => ''], 'post');
+
+        $val = Validate::rule([
+            'token' => 'require',
+            'process_id|流程id' => 'require|number|gt:0',
+            'action_type|节点类型' => 'require|number|between:' . APModel::$action_type_start . ',' . APModel::$action_type_end,
+            'operation_type|操作类型' => 'require|number|in:' . APModel::$operation_type_approval . ',' . APModel::$operation_type_system,
+            'status_name|节点名称' => 'require|max:255',
+            'order_process|节点值' => 'require|number|egt:0|checkOrderProcess:',
+            'next_action_ids|下一节点' => 'array|requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
+        ]);
+
+
+        $val->extend('checkOrderProcess', function ($val, $rule, $data) {
+            return APModel::where([
+                'process_id' => $data['process_id'],
+                'order_process' => $val,
+                'is_del' => APModel::$is_del_normal
+            ])->field('id')->findOrEmpty()->isEmpty() ? true : '同一个流程编码下该节点值已存在';
+        });
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        $user = GetUserInfo($param['token']);
+
+        $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
+        $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $date = date('Y-m-d H:i:s');
+
+        return APModel::create(array_merge($param, [
+            'status' => APModel::$status_disable,
+            'is_del' => APModel::$is_del_normal,
+            'createrid' => $uid,
+            'creater' => $uname,
+            'addtime' => $date,
+            'updaterid' => $uid,
+            'updater' => $uname,
+            'updatetime' => $date,
+        ]))->save() ? app_show(0, '新增流程节点成功') : error_show(1005, '新增流程节点失败');
+
+    }
+
+    //读取
+    public function read()
+    {
+
+        $id = $this->request->filter('trim')->post('id/d', 0);
+
+        $res = APModel::field(true)
+            ->where(['id' => $id, 'is_del' => APModel::$is_del_normal])
+            ->withAttr('next_action_ids', function ($val) {
+                return explode(',', $val);
+            })
+            ->findOrEmpty()
+            ->toArray();
+
+        return app_show(0, '请求成功', $res);
+    }
+
+    //修改
+    public function update()
+    {
+
+        $param = $this->request->filter('trim')->only(['token', 'id', 'process_id', 'action_type', 'operation_type', 'status_name', 'order_process', 'next_action_ids', 'remark' => '', 'status', 'is_del'], 'post');
+
+        $val = Validate::rule([
+            'token' => 'require',
+            'id|ID' => 'require|number|gt:0',
+            'process_id' => 'number|gt:0',
+            'action_type|节点类型' => 'number|between:' . APModel::$action_type_start . ',' . APModel::$action_type_end,
+            'operation_type|操作类型' => 'number|in:' . APModel::$operation_type_approval . ',' . APModel::$operation_type_system,
+            'status_name|节点名称' => 'max:255',
+            'order_process|节点值' => 'number|egt:0|checkOrderProcess:',
+            'next_action_ids|下一节点' => 'array|requireIf:action_type,' . APModel::$action_type_start . '|requireIf:action_type,' . APModel::$action_type_process,
+            'is_del|是否删除' => 'eq:' . APModel::$is_deleted,
+            'status|状态' => 'in:' . APModel::$status_disable . ',' . APModel::$status_normal,
+        ]);
+
+
+        $val->extend('checkOrderProcess', function ($val, $rule, $data) {
+            if (isset($val) && isset($data['process_id'])) return APModel::where(['process_id' => $data['process_id'], 'order_process' => $val, 'is_del' => APModel::$is_del_normal])->where('id', '<>', $data['id'])->field('id')->findOrEmpty()->isEmpty() ? true : '同一个流程编码下该节点值已存在';
+            else return true;
+        });
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        $info = APModel::where(['id' => $param['id'], 'is_del' => APModel::$is_del_normal])
+            ->field('id,process_id')
+            ->findOrEmpty();
+
+        if($info->isEmpty()) return error_show(1005,'该节点记录不存在');
+
+        if (isset($param['status']) && $param['status'] == APModel::$status_disable) {
+            //禁用节点时,要校验其所属流程是否被禁用
+            $p_info = PModel::field('id')
+                ->where(['id' => $info->process_id, 'is_del' => PModel::$is_del_normal, 'status' => PModel::$status_normal])
+                ->findOrEmpty()
+                ->isEmpty();
+
+            if (!$p_info) return error_show(1005, '该节点所属流程尚未禁用');
+
+        }
+
+        $user = GetUserInfo($param['token']);
+
+        $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
+        $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $date = date('Y-m-d H:i:s');
+
+        if (isset($param['next_action_ids']) && is_array($param['next_action_ids'])) $param['next_action_ids'] = implode(',', $param['next_action_ids']);
+
+        return APModel::where(['id' => $param['id'], 'is_del' => APModel::$is_del_normal])->strict(false)->save(array_merge($param, ['updaterid' => $uid, 'updater' => $uname, 'updatetime' => $date])) ? app_show(0, '修改流程节点成功') : error_show(1005, '修改流程节点失败');
+
+    }
+
+    //获取所有流程的所有节点
+    public function getAll()
+    {
+
+        $data = PModel::where(['is_del' => PModel::$is_del_normal, 'status' => PModel::$status_normal])
+            ->order(['weight'=>'desc','id'=>'desc'])
+            ->column('id,process_name,process_type', 'id');
+
+        $action = APModel::where(['is_del' => APModel::$is_del_normal, 'status' => APModel::$status_normal, 'operation_type' => APModel::$operation_type_approval])
+            ->field('id,process_id,order_process,status_name')
+            ->cursor();
+
+        foreach ($action as $item) {
+            $data[$item->process_id]['child'][] = $item->toArray();
+        }
+
+        return app_show(0, '请求成功', array_column($data, null, null));
+
+    }
+
+
+}

+ 10 - 1
app/admin/controller/Activity.php

@@ -437,7 +437,16 @@ class Activity extends Base
 
                 $stn = ["order_code" => $activity_code, "status" => $old_activity_status, "action_remark" => '', "action_type" => "status"];
                 ActionLog::logAdd($this->post['token'], $stn, "HD", $activity['status'], $activity);
-                $process = ["order_code" => $activity_code, "order_id" => $activity['id'], "order_status" => $activity['status'], "order_type" => 'HD', "before_status" => $old_activity_status];
+
+                //查找财务主管
+                $user = Db::name('role')
+                    ->field('r.id,u.uid,u.nickname')
+                    ->alias('r')
+                    ->leftJoin('user_role ur', 'ur.roleid=r.id AND ur.is_del=0')
+                    ->leftJoin('depart_user u', 'u.uid=ur.uid AND u.is_del=0 AND u.status=1')
+                    ->where('r.id', 20)//财务负责人
+                    ->findOrEmpty();
+                $process = ["order_code" => $activity_code, "order_id" => $activity['id'], "order_status" => $activity['status'], "order_type" => 'HD', "before_status" => $old_activity_status, 'wait_id' => isset($user['uid']) ? $user['uid'] : 0, 'wait_name' => isset($user['nickname']) ? $user['nickname'] : ''];
                 ProcessOrder::AddProcess($this->post['token'], $process);
 
                 Db::commit();

+ 8 - 6
app/admin/controller/After.php

@@ -52,8 +52,7 @@ class After extends Base
             return error_show(1005,"未找到退货原因数据");
         }
         $remark =isset($this->post['remark']) &&$this->post['remark']!=''?trim($this->post['remark']) :"";
-        $is_receive =isset($this->post['is_receive']) &&$this->post['is_receive']!==''?intval($this->post['is_receive'])
-            :"";
+        $is_receive =isset($this->post['is_receive']) &&$this->post['is_receive']!==''?intval($this->post['is_receive']):"";
         if($is_receive===""){
             return error_show(1004,"参数 is_receive 不能为空");
         }
@@ -126,7 +125,7 @@ class After extends Base
 
                 Db::execute("UPDATE `wsm_standing_book` SET `returnCode`=CONCAT(`returnCode`,',{$returnCode}'),`updatetime`='" . date('Y-m-d H:i:s') . "' WHERE FIND_IN_SET('{$outCode}',`outCode`)");
 
-                    $process=["order_code"=>$returnCode,"order_id"=>$create,"order_status"=>$in['status'],"order_type"=>'SHD',"before_status"=>1];
+                $process = ["order_code" => $returnCode, "order_id" => $create, "order_status" => $in['status'], "order_type" => 'SHD', "before_status" => 1];
                     ProcessOrder::AddProcess($token,$process);
                     Db::commit();
                     return app_show(0,"售后申请单新建成功",["returnCode"=>$returnCode]);
@@ -320,8 +319,7 @@ class After extends Base
         if(empty($info)){
             return error_show(1005,"未找到售后数据");
         }
-        $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status'])
-            :"";
+        $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']) :"";
         if($status===""){
             return error_show(1005,"参数status 不能为空");
         }
@@ -403,7 +401,11 @@ class After extends Base
                 }
                 $order = ["order_code"=>$info['returnCode'],"status"=>$var,"action_remark"=>'',"action_type"=>"edit"];
                 ActionLog::logAdd($this->post['token'],$order,"SHD", $info['status'],$this->post);
-                $process=["order_code"=>$info['returnCode'],"order_id"=>$info['id'],"order_status"=>$status,"order_type"=>"SHD","before_status"=>$var];
+
+                if (in_array($status, [2, 3])) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['cgderid'], 'wait_name' => $info['cgder']];
+                elseif ($status == 4) $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var, 'wait_id' => $info['apply_id'], 'wait_name' => $info['apply_name']];
+                else $process = ["order_code" => $info['returnCode'], "order_id" => $info['id'], "order_status" => $status, "order_type" => "SHD", "before_status" => $var];
+
                 ProcessOrder::AddProcess($this->post['token'],$process);
                 Db::commit();
                 return app_show(0,"更新成功");

+ 12 - 10
app/admin/controller/Consult.php

@@ -246,27 +246,28 @@ class Consult extends Base
                         "updatetime"=>date("Y-m-d H:i:s"),
                         'enclosure_file'=>isset($value['enclosure_file'])?$value['enclosure_file']:'',
                     ];
-                    $up = Db::name("consult_info")->insert($info);
+                    $up = Db::name("consult_info")->insertGetId($info);
                     if(!$up){
                         Db::rollback();
                         return error_show(1004,'添加失败');
                     }else{
-                        //修改状态,添加待办
-                        ActionLog::logAdd($this->post['token'], [
+                        //修改状态
+                        ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
                             "order_code" => $infoNo,//咨询单详情编号
                             "status" => 1,//这里的status是之前的值
                             "action_remark" => '',//备注
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "ZXD", 1, $info);
 
-//                        ProcessOrder::AddProcess($this->post['token'], [
+                        //竞价单不走流程,不推待办已办
+//                        ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
 //                            "order_type" => 'ZXD',
 //                            "order_code" => $infoNo,//咨询单详情编号
-//                            "order_id" => 0,
-//                            "order_status" => 1
+//                            "order_id" => $up,
+//                            "order_status" => 1,
+//                            'before_status'=>0
 //                        ]);
 
-
                         //如果存在该项目编码,更新对应的第一个竞价单编码,其他竞价单编码新增(带着项目编码)
                         if (isset($stand_exists)) {
                             Db::name('standing_book')
@@ -1346,7 +1347,7 @@ class Consult extends Base
                 'bargain_remark'=>$bargain_remark,
                 'result_info_id'=>$result_info_id,
             ];
-            $int = Db::name("bargain_order")->insert($data);
+            $int = Db::name("bargain_order")->insertGetId($data);
             if($int){
                 //修改状态,添加待办
                 ActionLog::logAdd($this->post['token'], [
@@ -1359,8 +1360,9 @@ class Consult extends Base
                 ProcessOrder::AddProcess($this->post['token'], [
                     "order_type" => 'YJD',
                     "order_code" => $bargainNo,
-                    "order_id" =>Db::name("bargain_order")->getLastInsID(),
-                    "order_status" =>0,"before_status"=>0
+                    "order_id" => $int,
+                    "order_status" =>0,
+                    "before_status"=>0
                 ]);
                 $odlstatus=$info['status'];
                 $info['status']=3;

+ 13 - 5
app/admin/controller/Goodup.php

@@ -373,6 +373,8 @@ class Goodup extends Base
 //        if($is_step==1 &&  $good_ladder==""){
 //            return error_show(1004,"启用阶梯,阶梯价不能为空");
 //        }
+        $is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
+
         $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
         if($token==''){
             return error_show(105,"参数token不能为空");
@@ -447,9 +449,10 @@ class Goodup extends Base
                 "createrid"=>$createrid,
                 "creater"=>$creater,
                 "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
+                "updatetime"=>date("Y-m-d H:i:s"),
+                'is_support_barter'=>$is_support_barter
             ];
-            $in = Db::name("good_basic")->insert($data);
+            $in = Db::name("good_basic")->insertGetId($data);
             if($in){
                 if($speclist!=="" && !empty($speclist)){
                     $temp=[];
@@ -523,7 +526,7 @@ class Goodup extends Base
                         ProcessOrder::AddProcess($this->post['token'], [
                             "order_type" => 'SPCB',
                             "order_code" => $spucode,//咨询单详情编号
-                            "order_id" => Db::name("good_basic")->getLastInsID(),
+                            "order_id" => $in,
                             "order_status" =>0,"before_status"=>0
                         ]);
                     Db::commit();
@@ -1023,6 +1026,7 @@ class Goodup extends Base
 //                    ->whereIn('spuCode', $supcode)
 //                    ->update(['status' => 2, 'updatetime' => date('Y-m-d H:i:s')]);
 //            }
+            $old_status = $data['status'];
             $data['status']=$status;
             $data['updatetime']=date("Y-m-d H:i:s");
             $up= Db::name("good_basic")->save($data);
@@ -1039,7 +1043,7 @@ class Goodup extends Base
                     "order_type" => 'SPCB',
                     "order_code" => $supcode,//咨询单详情编号
                     "order_id" => $data['id'],
-                    "order_status" =>$data['status'],"before_status"=>$status
+                    "order_status" =>$data['status'],"before_status"=>$old_status
                 ]);
                 $data=[
                     "code"=>$supcode,
@@ -2106,6 +2110,9 @@ class Goodup extends Base
 //            return error_show(1004,"启用阶梯,阶梯价不能为空");
 //        }
         $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
+
+        $is_support_barter = isset($this->post['is_support_barter']) && $this->post['is_support_barter'] !== "" ? intval($this->post['is_support_barter']) : 1;
+
         Db::startTrans();
         try {
             $temp=[
@@ -2162,7 +2169,8 @@ class Goodup extends Base
                 "is_step" => count($good_ladder) > 1 ? 1 : 0,
                 "stock_moq"=>$stock_moq,
                 "status"=>"0",
-                "updatetime"=>date("Y-m-d H:i:s")
+                "updatetime"=>date("Y-m-d H:i:s"),
+                'is_support_barter'=>$is_support_barter
             ];
             $field = array_diff_assoc($temp,$data);
             $temp['field_change'] =empty($field)?"":json_encode(array_keys($field));

+ 158 - 27
app/admin/controller/Process.php

@@ -2,18 +2,22 @@
 
 
 namespace app\admin\controller;
+
 use app\BaseController;
 use think\App;
 use think\facade\Db;
+use think\facade\Validate;
+use app\admin\model\Process as ProcessModel;
+use app\admin\model\ActionProcess as APModel;
 
 //流程单
 class Process extends Base
 {
 
- public function __construct(App $app)
- {
-     parent::__construct($app);
- }
+    public function __construct(App $app)
+    {
+        parent::__construct($app);
+    }
 
     /**
      * @return \think\response\Json|void
@@ -21,16 +25,17 @@ class Process extends Base
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-  public function list(){
-     $page =isset($this->post['page']) &&$this->post['page']!="" ? intval($this->post['page']) : 1;
-     $size =isset($this->post['size']) &&$this->post['size']!="" ? intval($this->post['size']) : 10;
+    public function list()
+    {
+        $page = isset($this->post['page']) && $this->post['page'] != "" ? intval($this->post['page']) : 1;
+        $size = isset($this->post['size']) && $this->post['size'] != "" ? intval($this->post['size']) : 10;
 
-     $count = Db::name("process")->where('is_del',0)->count();
-     $total = ceil($count/$size);
-     $page = $page>$total ? $total:$page;
-      $list = Db::name("process")->where('is_del', 0)->page($page, $size)->select();
-     return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
-  }
+        $count = Db::name("process")->where('is_del', 0)->count();
+        $total = ceil($count / $size);
+        $page = $page > $total ? $total : $page;
+        $list = Db::name("process")->where('is_del', 0)->page($page, $size)->select();
+        return app_show(0, "获取成功", ["list" => $list, "count" => $count]);
+    }
 
     /**
      * @return \think\response\Json|void
@@ -38,19 +43,20 @@ class Process extends Base
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-  public  function info(){
-    $id =isset($this->post['id']) &&$this->post['id']!="" ? intval($this->post['id']) : "";
-    if($id==""){
-        return error_show(1004,"参数id 不能为空");
-    }
-    $info = Db::name("process")->where(['id'=>$id,"is_del"=>0])->find();
-    if(empty($info)){
-        return error_show(1004,"流程信息未找到");
+    public function info()
+    {
+        $id = isset($this->post['id']) && $this->post['id'] != "" ? intval($this->post['id']) : "";
+        if ($id == "") {
+            return error_show(1004, "参数id 不能为空");
+        }
+        $info = Db::name("process")->where(['id' => $id, "is_del" => 0])->find();
+        if (empty($info)) {
+            return error_show(1004, "流程信息未找到");
+        }
+        $list = Db::name("action_process")->where(["pid" => $id, "is_del" => 0])->order("weight,id")->select();
+        $info['item'] = empty($list) ? [] : $list;
+        return app_show(0, "获取成功", $info);
     }
-    $list=Db::name("action_process")->where(["pid"=>$id,"is_del"=>0])->order("weight,id")->select();
-    $info['item'] = empty($list) ? []:$list;
-    return app_show(0,"获取成功",$info);
-  }
 
     /**
      * @return \think\response\Json|void
@@ -80,8 +86,8 @@ class Process extends Base
             ->where(["order_type" => $process_type])
             ->whereIn('action_process', $order_process_s)
             ->field('id,action_uid,action_name,addtime,action_process,order_type');
-        if(is_numeric($orderCode))  $rs->where('order_id',$orderCode);
-        else $rs->where('order_code',$orderCode);
+        if (is_numeric($orderCode)) $rs->where('order_id', $orderCode);
+        else $rs->where('order_code', $orderCode);
 
         $node = $rs
             ->select()
@@ -113,4 +119,129 @@ class Process extends Base
         return app_show(0, "获取成功", $node);
     }
 
+
+    //获取流程列表
+    public function getList()
+    {
+        $param = $this->request->filter('trim')->only(['status' => '', 'process_name' => '', 'creater' => '', 'addtime_start' => '', 'addtime_end' => '', 'page' => 1, 'size' => 15], 'post');
+
+        $where = [['is_del', '=', ProcessModel::$is_del_normal]];
+        if ($param['status'] != '') $where[] = ['status', '=', $param['status']];
+        if ($param['process_name'] != '') $where[] = ['process_name', 'like', '%' . $param['process_name'] . '%'];
+        if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
+        if ($param['addtime_start'] != '' && $param['addtime_end'] != '') $where[] = ['addtime', 'between', [$param['addtime_start'], $param['addtime_end'] . ' 23:59:59']];
+
+        $count = Db::name('process')
+            ->where($where)
+            ->count('id');
+
+        $list = ProcessModel::field('id,process_name,process_type,status,creater,addtime')
+            ->where($where)
+            ->order(['weight'=>'desc','id'=>'desc'])
+            ->page($param['page'], $param['size'])
+            ->select()
+            ->toArray();
+
+        return app_show(0, '获取成功', ['count' => $count, 'list' => $list]);
+
+    }
+
+    //增加流程
+    public function add()
+    {
+        $param = $this->request->filter('trim')->only(['token', 'process_name', 'process_type', 'remark' => ''], 'post');
+
+        $val = Validate::rule([
+            'token' => 'require',
+            'process_name|流程名称' => 'require|max:255',
+            'process_type|流程值' => 'require|max:255|checkProcessType:',
+        ]);
+
+        $val->extend('checkProcessType', function ($val) {
+            return ProcessModel::where(['process_type' => $val, 'is_del' => ProcessModel::$is_del_normal])->field('id')->findOrEmpty()->isEmpty() ? true : '该流程值已存在';
+        });
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        $user = GetUserInfo($param['token']);
+
+        $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
+        $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $date = date('Y-m-d H:i:s');
+
+        return ProcessModel::create(array_merge($param, [
+            'is_del' => ProcessModel::$is_del_normal,
+            'status' => ProcessModel::$status_disable,
+            'createrid' => $uid,
+            'creater' => $uname,
+            'addtime' => $date,
+            'updaterid' => $uid,
+            'updater' => $uname,
+            'updatetime' => $date,
+        ]))->save() ? app_show(0, '新增流程成功') : error_show(1005, '新增流程失败');
+
+    }
+
+    //读取
+    public function read()
+    {
+        $id = $this->request->filter('trim')->post('id/d', 0);
+
+        $res = ProcessModel::field('id,process_name,process_type')
+            ->where(['id' => $id, 'is_del' => ProcessModel::$is_del_normal])
+            ->findOrEmpty()
+            ->toArray();
+
+        return app_show(0, '获取详情成功', $res);
+    }
+
+    //修改流程
+    public function update()
+    {
+        $param = $this->request->filter('trim')->only(['token', 'id', 'process_name', 'process_type', 'status', 'is_del', 'remark'], 'post');
+
+        $val = Validate::rule([
+            'token' => 'require',
+            'id|ID' => 'require|number|gt:0',
+            'process_name|流程名称' => 'max:255',
+            'process_type|流程值' => 'max:255|checkProcessType:',
+            'status|状态' => 'number|in:' . ProcessModel::$status_normal . ',' . ProcessModel::$status_disable,
+            'is_del|是否删除' => 'number|eq:' . ProcessModel::$is_deleted,
+        ]);
+
+        $val->extend('checkProcessType', function ($val, $rule, $data) {
+            return ProcessModel::where(['process_type' => $val, 'is_del' => ProcessModel::$is_del_normal])->where('id', '<>', $data['id'])->field('id')->findOrEmpty()->isEmpty() ? true : '该流程值已存在';
+        });
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        if (isset($param['status']) && $param['status'] == ProcessModel::$status_normal) {
+            //启用流程时候,校验该流程下有没有开始节点和结束节点
+            $ap_info = APModel::where([
+                'process_id' => $param['id'],
+                'is_del' => APModel::$is_del_normal,
+                'status' => APModel::$status_normal
+            ])->whereIn('action_type', [
+                APModel::$action_type_start,
+                APModel::$action_type_end
+            ])->column('id', 'action_type');
+
+            if (count($ap_info) != 2) return error_show(1005, '该流程下缺少开始节点和结束节点');
+        }
+
+        $user = GetUserInfo($param['token']);
+
+        $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
+        $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $date = date('Y-m-d H:i:s');
+
+        return ProcessModel::where(['id' => $param['id'], 'is_del' => ProcessModel::$is_del_normal])->strict(false)->save(array_merge($param, [
+            'updaterid' => $uid,
+            'updater' => $uname,
+            'updatetime' => $date,
+        ])) ? app_show(0, '修改流程成功') : error_show(1005, '修改流程失败');
+
+    }
+
+
 }

+ 9 - 8
app/admin/controller/Project.php

@@ -111,11 +111,11 @@ class Project extends Base
 
                         $in = Db::name("project_info")->insert($temp,true);
                         if($in>0){
-                            ActionLog::logAdd($this->post['token'], [
+                            ActionLog::logAdd(['id'=>$createrid,'nickname'=>$creater], [
                                 "order_code" => $pgNo,//编码,这里是project的编码
                                 "status" => 1,//这里的status是之前的值
                                 "action_remark" => '',//备注
-                                "action_type" => "status"//新建create,编辑edit,更改状态status
+                                "action_type" => "create"//新建create,编辑edit,更改状态status
                             ], "PRI", 1, $temp);
                         }else{
                             Db::rollback();
@@ -123,25 +123,26 @@ class Project extends Base
                         }
 
                     }
+
                     //修改状态,添加待办
-                    ActionLog::logAdd($this->post['token'], [
+                    ActionLog::logAdd(['id'=>$createrid,'nickname'=>$creater], [
                         "order_code" => $projectNo,//项目编码
                         "status" =>0,//这里的status是之前的值
                         "action_remark" => '',//备注
-                        "action_type" => "edit"//新建create,编辑edit更改状态status
+                        "action_type" => "create"//新建create,编辑edit更改状态status
                     ], "PRT", 1, $this->post);
 
                     $process = ["order_code" => $projectNo, "order_id" => Db::name("project")->getLastInsID(), "order_status" =>1, "order_type" => 'PRT',"before_status"=>1];//order_status==7修改毛利率
-                    ProcessOrder::AddProcess($this->post['token'], $process);
+                    ProcessOrder::AddProcess(['id'=>$createrid,'nickname'=>$creater], $process);
                         //修改状态,添加待办,只记录动作
-                        ActionLog::logAdd($this->post['token'], [
+                        ActionLog::logAdd(['id'=>$createrid,'nickname'=>$creater], [
                             "order_code" => $projectNo,//编码,这里是project的编码
                             "status" => 1,//这里的status是之前的值
                             "action_remark" => '',//备注
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "PRO", 1, $this->post);
-                        $process = ["order_code" => $projectNo, "order_id" => Db::name("project")->getLastInsID(), "order_status" =>1, "order_type" =>"PRO","before_status"=>1];
-                        ProcessOrder::AddProcess($this->post['token'], $process);
+                        $process = ["order_code" => $projectNo, "order_id" => $pro, "order_status" =>1, "order_type" =>"PRO","before_status"=>1];
+                        ProcessOrder::AddProcess(['id'=>$createrid,'nickname'=>$creater], $process);
 
                     //台账记录
                     Db::name('standing_book')

+ 137 - 74
app/admin/controller/Proorder.php

@@ -14,82 +14,145 @@ public function __construct(App $app)
     parent::__construct($app);
 }
 
-public function list(){
-    $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']) :"1";
-    $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']) :"10";
-    $where =[['is_del',"=",0],['a.order_status',"=",2]];
-    $role=$this->checkRole();
-    if(!empty($role['write'])){
-        $where[]=["a.action_uid","in",$role['write']];
-    }
-    $count = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")->where($where)->count();
-    $total = ceil("$count/$size");
-    $page = $page>$total ? $total:$page;
-    $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
-        ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.action_status,a.order_type,a.action_process,a.order_code,a.order_id,a.id")
-        ->where($where)->page($page,$size)->order("a.addtime desc")->select();
-    $data=[];
-    foreach ($list as $value){
-        $str = Db::name("process")->where(['process_type' => $value['order_type']])->field("process_name,status")->find();
-        $var = Db::name("action_process")->where(['order_type'=>$value['order_type'],'order_process'=>$value['action_status']])->field("status_name,order_process,order_name,roleid")->find();
-        $value['process_name']=$str['process_name'];
-        $value['order_name']=$var['order_name'];
-        $value['status_name'] = $var['status_name'];
-        $data[]=$value;
-    }
-    return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
-}
-public function waitlist(){
-    $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']) :"1";
-    $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']) :"10";
-    $where = [['is_del',"=",0],['a.status',"=",1]];
-    $role=$this->checkRole();
-    $comd='';
-    if(!empty($role['write']) || $role['roleid']==33){
-        $comd.="FIND_IN_SET({$role['roleid']},roleid) >0";
-    }
-    $order_code= isset($this->post['order_code']) && $this->post['order_code'] !==""? intval($this->post['order_code']):"";
-    if($order_code!=""){
-        $where[]= ["a.order_code",'like',"%$order_code%"];
-    }
-    $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !==""? trim($this->post['apply_id']) :"";
-    if($apply_id!=""){
-        $where[]=["a.wait_id","=",$apply_id];
-    }
-    $action_uid = isset($this->post['action_uid']) && $this->post['action_uid'] !==""? trim($this->post['action_uid']) :"";
-    if($action_uid!=""){
-        $where[]=["a.action_uid","=",$action_uid];
+
+    //已读列表
+    public function list()
+    {
+
+        /**暂时屏蔽
+         * $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']) :"1";
+         * $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']) :"10";
+         * $where =[['is_del',"=",0],['a.order_status',"=",2]];
+         * $role=$this->checkRole();
+         * if(!empty($role['write'])){
+         * $where[]=["a.action_uid","in",$role['write']];
+         * }
+         * $count = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")->where($where)->count();
+         * $total = ceil("$count/$size");
+         * $page = $page>$total ? $total:$page;
+         * $list = Db::name('process_order')->alias("a")->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
+         * ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.action_status,a.order_type,a.action_process,a.order_code,a.order_id,a.id")
+         * ->where($where)->page($page,$size)->order("a.addtime desc")->select();
+         * $data=[];
+         * foreach ($list as $value){
+         * $str = Db::name("process")->where(['process_type' => $value['order_type']])->field("process_name,status")->find();
+         * $var = Db::name("action_process")->where(['order_type'=>$value['order_type'],'order_process'=>$value['action_status']])->field("status_name,order_process,order_name,roleid")->find();
+         * $value['process_name']=$str['process_name'];
+         * $value['order_name']=$var['order_name'];
+         * $value['status_name'] = $var['status_name'];
+         * $data[]=$value;
+         * }
+         * return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
+         * **/
+
+        {
+
+            $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
+
+            $db = Db::name('process_wait')
+                ->alias("a")
+                ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
+                ->where(['is_del' => 0, 'a.status' => 2]);
+
+            $db->where(function ($query) use ($param) {
+                //所属角色
+                $role = $this->checkRole();
+                if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
+
+                //本人id
+                $user = GetUserInfo($param['token']);
+                if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
+            });
+
+            if ($param['order_code'] != '') $db->whereLike("a.order_code", '%' . $param['order_code'] . '%');
+            if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
+
+            $count = $db->count();
+
+            $total = ceil($count / $param['size']);
+            $page = $param['page'] > $total ? $total : $param['page'];
+            $list = $db
+                ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id")
+                ->page($page, $param['size'])
+                ->order("a.addtime desc")
+                ->select()
+                ->toArray();
+
+            //所有流程名称
+            $all_process = Db::name("process")
+                ->whereIn('process_type', array_column($list, 'order_type'))
+                ->column("process_name", 'process_type');
+
+            $data = [];
+            foreach ($list as $value) {
+                $var = Db::name("action_process")
+                    ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
+                    ->field("status_name,order_process,order_name,roleid")
+                    ->find();
+                $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
+                $value['order_name'] = $var['order_name'];
+                $value['status_name'] = $var['status_name'];
+                $data[] = $value;
+            }
+            return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
+        }
+
+
     }
-    $count = Db::name('process_wait')
-        ->alias("a")
-        ->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
-        ->where($comd)
-        ->where($where)
-        ->count();
-
-    $total = ceil("$count/$size");
-    $page = $page>$total ? $total:$page;
-    $list = Db::name('process_wait')
-        ->alias("a")
-        ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id")
-        ->leftJoin("workflow b","a.order_type=b.order_type and a.order_code=b.order_code")
-        ->where($where)
-        ->where($comd)
-        ->page($page,$size)
-        ->order("a.addtime desc")
-        ->cursor();
-
-    $data=[];//->field("status,order_name,process_name")
-    foreach ($list as $value) {
-        $str = Db::name("process")->where(['process_type' => $value['order_type']])->field("process_name,status")->find();
-        $var = Db::name("action_process")->where(['order_type'=>$value['order_type'],'order_process'=>$value['order_status']])->field("status_name,order_process,order_name,roleid")->find();
-        $value['process_name']=$str['process_name'];
-        $value['order_name']=$var['order_name'];
-        $value['status_name'] = $var['status_name'];
-        $data[]=$value;
+
+    //待处理列表
+    public function waitlist()
+    {
+
+        $param = $this->request->filter('trim')->only(['token', 'apply_id' => '', 'action_uid' => '', 'order_code' => '', 'page' => 1, 'size' => 10], 'post');
+
+        $db = Db::name('process_wait')
+            ->alias("a")
+            ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
+            ->where(['is_del' => 0, 'a.status' => 1]);
+
+        $db->where(function ($query) use ($param) {
+            //所属角色
+            $role = $this->checkRole();
+            if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
+
+            //本人id
+            $user = GetUserInfo($param['token']);
+            if (isset($user['data']['id'])) $query->whereOr('wait_id', $user['data']['id']);
+        });
+
+        if ($param['order_code'] != '') $db->whereLike('a.order_code', '%' . $param['order_code'] . '%');
+        if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
+
+        $count = $db->count();
+
+        $total = ceil($count / $param['size']);
+        $page = $param['page'] > $total ? $total : $param['page'];
+        $list = $db
+            ->field("a.id,b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id")
+            ->page($page, $param['size'])
+            ->order("a.addtime desc")
+            ->select()
+            ->toArray();
+
+        //所有流程名称
+        $all_process = Db::name("process")
+            ->whereIn('process_type', array_column($list, 'order_type'))
+            ->column("process_name", 'process_type');
+
+        $data = [];
+        foreach ($list as $value) {
+            $var = Db::name("action_process")
+                ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
+                ->field("status_name,order_process,order_name,roleid")
+                ->find();
+            $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
+            $value['order_name'] = $var['order_name'];
+            $value['status_name'] = $var['status_name'];
+            $data[] = $value;
+        }
+        return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
     }
-    return app_show(0,"获取成功",["list"=>$data,'count'=>$count]);
-}
 public function all(){
     $token = isset($this->post['token']) ? trim($this->post['token']) : "";
     if($token==""){

+ 15 - 4
app/admin/controller/Purch.php

@@ -628,6 +628,12 @@ class Purch extends Base
 //        $data['status'] = $status;
 //        $data['remark'] = $remark;
 //        $data['updatetime'] =date("Y-m-d H:i:s");
+
+        //原始数据
+        $info = Db::name("purchease_order")
+            ->whereIn('cgdNo', $cgdNo)
+            ->column('id,cgdNo,status','cgdNo');
+
         $upd = Db::name("purchease_order")
             ->whereIn('cgdNo', $cgdNo)
             ->save([
@@ -636,11 +642,16 @@ class Purch extends Base
                 'updatetime' => date("Y-m-d H:i:s"),
             ]);
         if ($upd) {
-            foreach ($cgdNo as $vlue){
-                $process = ["order_code" => $vlue, "order_id" => 0, "order_status" => $status, "order_type" => 'CGD',"before_status"=>0];
-                ProcessOrder::AddProcess($this->post['token'], $process);
+
+            $user=GetUserInfo($this->post['token']);
+            $uid = isset($user['data']['id'])?$user['data']['id']:0;
+            $uname = isset($user['data']['nickname'])?$user['data']['nickname']:'';
+
+            foreach ($cgdNo as $vlue) {
+                $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0];
+                ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], $process);
                 $order = ["order_code" => $vlue, "status" => '', "action_remark" => $remark, "action_type" => "status"];
-                ActionLog::logAdd($this->post['token'], $order, 'CGD', $status, $this->post);
+                ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], $order, 'CGD', $status, $this->post);
             }
             return app_show(0, "更新成功");
         } else {

+ 1 - 1
app/admin/controller/Resign.php

@@ -891,7 +891,7 @@ class Resign extends Base
                         $order = ["order_code" =>  $cgdCode, "status" => 0, "action_remark" => '', "action_type" => "create"];
                         GoodLog::LogAdd($this->post['token'], $good_data, 'CGD');
                         ActionLog::logAdd($this->post['token'], $order, "CGD", 0, $good);
-                        $process = ["order_code" => $cgdCode, "order_id" => Db::name("purchease_order")->getLastInsID(), "order_status" => $cg['status'], "order_type" => 'CGD',"before_status"=>0];
+                        $process = ["order_code" => $cgdCode, "order_id" => $up, "order_status" => $cg['status'], "order_type" => 'CGD',"before_status"=>0];
                         ProcessOrder::AddProcess($this->post['token'], $process);
                         $info['wsm_code'] = $wsm_code;
                         $old_info_status = $info['status'];

+ 110 - 0
app/admin/controller/Role.php

@@ -6,6 +6,9 @@ use app\BaseController;
 use think\App;
 use think\facade\Db;
 use app\admin\model\ActionLog;
+use think\facade\Validate;
+use app\admin\model\ActionProcess as APModel;
+use app\admin\model\Process as PModel;
 
 //角色
 class Role extends BaseController
@@ -373,4 +376,111 @@ class Role extends BaseController
         $list =Db::name("role")->select();
         return app_show(0,"获取成功",$list);
     }
+
+
+    //获取角色对应的流程权限id
+    public function roleProcessInfo()
+    {
+        $roleid = $this->request->filter('trim')->post('roleid/d', 0);
+
+        $res = Db::name("role")
+            ->alias("a")
+            ->leftJoin("role_process b", "a.id=b.role_id AND b.is_del=0")
+            ->field("a.*,b.action_data")
+            ->withAttr('action_data', function ($val) {
+                return explode(',', $val);
+            })
+            ->where("a.id", $roleid)
+            ->findOrEmpty();
+
+        return app_show(0, '请求成功', $res);
+
+    }
+
+    //修改角色对应的流程权限
+    public function roleProcessSave()
+    {
+        $param = $this->request->filter('trim')->only(['token', 'roleid', 'action_data'], 'post');
+
+        $val = Validate::rule([
+            'token' => 'require',
+            'roleid|角色ID' => 'require|number|gt:0',
+            'action_data|所选节点id' => 'require|array',
+        ]);
+
+        if (!$val->check($param)) return error_show(1005, $val->getError());
+
+        $user = GetUserInfo($param['token']);
+
+        $uid = isset($user['data']['id']) ? $user['data']['id'] : 0;
+        $uname = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
+        $date = date('Y-m-d H:i:s');
+
+        $res = Db::name('role_process')
+            ->where(['is_del' => 0, 'role_id' => $param['roleid']])
+            ->field('id')
+            ->findOrEmpty();
+
+        if (empty($res)) {
+            $rs = Db::name('role_process')
+                ->insert([
+                    'role_id' => $param['roleid'],
+                    'action_data' => implode(',', $param['action_data']),
+                    'is_del' => 0,
+                    'createrid' => $uid,
+                    'creater' => $uname,
+                    'addtime' => $date,
+                    'updaterid' => $uid,
+                    'updater' => $uname,
+                    'updatetime' => $date,
+                ]);
+        } else {
+            $rs = Db::name('role_process')
+                ->where('id', $res['id'])
+                ->update([
+                    'action_data' => implode(',', $param['action_data']),
+                    'updaterid' => $uid,
+                    'updater' => $uname,
+                    'updatetime' => $date
+                ]);
+        }
+
+        return $rs ? app_show(0, '操作成功') : error_show(1005, '操作失败');
+
+    }
+
+    //获取角色对应的流程权限详情
+    public function roleProcessDetail()
+    {
+
+        $roleid = $this->request->filter('trim')->post('roleid/d', 0);
+
+        $action_data = Db::name("role_process")
+            ->where('role_id', $roleid)
+            ->value('action_data');
+
+        $data = PModel::where(['is_del' => PModel::$is_del_normal, 'status' => PModel::$status_normal])
+            ->append(['child'])
+            ->withAttr('child', function () {
+                return [];
+            })
+            ->column('id,process_name,process_type', 'id');
+
+        $action = APModel::where([
+            'is_del' => APModel::$is_del_normal,
+            'status' => APModel::$status_normal,
+            'operation_type' => APModel::$operation_type_approval
+        ])->whereIn('id', $action_data)
+            ->field('id,process_id,order_process,status_name')
+            ->cursor();
+
+        foreach ($action as $item) {
+            if (isset($data[$item->process_id])) $data[$item->process_id]['child'][] = $item->toArray();
+        }
+
+        return app_show(0, '请求成功', array_column($data, null, null));
+
+    }
+
+
 }

+ 32 - 26
app/admin/controller/Sale.php

@@ -406,23 +406,23 @@ class Sale extends Base
                                 "addtime" => date("Y-m-d H:i:s"),
                                 "updatetime" => date("Y-m-d H:i:s")
                             ];
-                            $ou = Db::name("order_out")->insert($out);
+                            $ou = Db::name("order_out")->insertGetId($out);
                             if ($ou == false) {
                                 Db::rollback();
                                 return error_show(1002, "发货地址添加创建失败");
                             } else {
                                 //修改状态,添加待办
-                                ActionLog::logAdd($this->post['token'], [
+                                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                                     "order_code" => $outCode,//出库单号
                                     "status" => $out['status'],//这里的status是之前的值
                                     "action_remark" => '',//备注
                                     "action_type" => "create"//新建create,编辑edit,更改状态status
                                 ], "CKD", $out['status'], $out);
 
-                                ProcessOrder::AddProcess($this->post['token'], [
+                                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                                     "order_type" => 'CKD',
                                     "order_code" => $outCode,//出库单号
-                                    "order_id" => Db::name("order_out")->getLastInsID(),
+                                    "order_id" => $ou,
                                     "order_status" => $out['status'], "before_status" => $out['status']
                                 ]);
 
@@ -773,23 +773,23 @@ class Sale extends Base
                         "addtime" => date("Y-m-d H:i:s"),
                         "updatetime" => date("Y-m-d H:i:s")
                     ];
-                    $ou = Db::name("order_out")->insert($out);
+                    $ou = Db::name("order_out")->insertGetId($out);
                     if ($ou == false) {
                         Db::rollback();
                         return error_show(1002, "发货地址添加创建失败");
                     } else {
                         //修改状态,添加待办
-                        ActionLog::logAdd($this->post['token'], [
+                        ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                             "order_code" => $outCode,//出库单号
                             "status" => 0,//这里的status是之前的值
                             "action_remark" => '',//备注
                             "action_type" => "create"//新建create,编辑edit,更改状态status
                         ], "CKD", 0, $out);
 
-                        ProcessOrder::AddProcess($this->post['token'], [
+                        ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                             "order_type" => 'CKD',
                             "order_code" => $outCode,//出库单号
-                            "order_id" => Db::name("order_out")->getLastInsID(),
+                            "order_id" => $ou,
                             "order_status" => $status, "before_status" => 0
                         ]);
 
@@ -1124,23 +1124,23 @@ class Sale extends Base
                                 "addtime" => date("Y-m-d H:i:s"),
                                 "updatetime" => date("Y-m-d H:i:s")
                             ];
-                            $ou = Db::name("order_out")->insert($out);
+                            $ou = Db::name("order_out")->insertGetId($out);
                             if ($ou == false) {
                                 Db::rollback();
                                 return error_show(1002, "发货地址添加创建失败");
                             } else {
                                 //修改状态,添加待办
-                                ActionLog::logAdd($this->post['token'], [
+                                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                                     "order_code" => $outCode,//出库单号
                                     "status" => 0,//这里的status是之前的值
                                     "action_remark" => '',//备注
                                     "action_type" => "create"//新建create,编辑edit,更改状态status
                                 ], "CKD", 0, $out);
 
-                                ProcessOrder::AddProcess($this->post['token'], [
+                                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                                     "order_type" => 'CKD',
                                     "order_code" => $outCode,//出库单号
-                                    "order_id" => Db::name("order_out")->getLastInsID(),
+                                    "order_id" => $ou,
                                     "order_status" => 0, "before_status" => 0
                                 ]);
 
@@ -1621,7 +1621,7 @@ class Sale extends Base
                             "addtime" => date("Y-m-d H:i:s"),
                             "updatetime" => date("Y-m-d H:i:s")
                         ];
-                        $ou = Db::name("order_out")->insert($out);
+                        $ou = Db::name("order_out")->insertGetId($out);
                         if ($ou == false) {
                             return false;
                         }
@@ -1636,7 +1636,7 @@ class Sale extends Base
                         ProcessOrder::AddProcess($this->post['token'], [
                             "order_type" => 'CKD',
                             "order_code" => $outCode,
-                            "order_id" => Db::name("order_out")->getLastInsID(),
+                            "order_id" => $ou,
                             "order_status" => 0, "before_status" => 0
                         ]);
                         $order['send_num'] += $value['receipt_quantity'];
@@ -1915,7 +1915,7 @@ class Sale extends Base
                             "addtime" => date("Y-m-d H:i:s"),
                             "updatetime" => date("Y-m-d H:i:s")
                         ];
-                        $ou = Db::name("order_out")->insert($out);
+                        $ou = Db::name("order_out")->insertGetId($out);
                         if ($ou == false) {
                             return 0;
                         } else {
@@ -1931,7 +1931,7 @@ class Sale extends Base
                             ProcessOrder::AddProcess($this->post['token'], [
                                 "order_type" => 'CKD',
                                 "order_code" => $outCode,//出库单号
-                                "order_id" => Db::name("order_out")->getLastInsID(),
+                                "order_id" => $ou,
                                 "order_status" => 0, "before_status" => 0
                             ]);
                         }
@@ -2536,7 +2536,7 @@ class Sale extends Base
                                 "addtime" => date("Y-m-d H:i:s"),
                                 "updatetime" => date("Y-m-d H:i:s")
                             ];
-                            $datainfo = Db::name('order_out')->insert($data);
+                            $datainfo = Db::name('order_out')->insertGetId($data);
                             if (!$datainfo) {
                                 $sti = ["order_code" => $dio['orderCode'], "status" => 0, "action_remark" => '', "action_type" => "create"];
                                 ActionLog::logAdd($this->post['token'], $sti, "xsd", 0, $sti);
@@ -2544,17 +2544,17 @@ class Sale extends Base
                                 return error_show(1003, "创建失败");
                             } else {
                                 //修改状态,添加待办
-                                ActionLog::logAdd($this->post['token'], [
+                                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                                     "order_code" => $outCode,//出库单号
                                     "status" => 0,//这里的status是之前的值
                                     "action_remark" => '',//备注
                                     "action_type" => "create"//新建create,编辑edit,更改状态status
                                 ], "CKD", 0, $data);
 
-                                ProcessOrder::AddProcess($this->post['token'], [
+                                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                                     "order_type" => 'CKD',
                                     "order_code" => $outCode,//出库单号
-                                    "order_id" => 0,
+                                    "order_id" => $datainfo,
                                     "order_status" => 0, "before_status" => 0
                                 ]);
                             }
@@ -3241,7 +3241,7 @@ class Sale extends Base
         $end_sendtime = isset($this->post['end_sendtime']) && $this->post['end_sendtime'] !== "" ? $this->post['end_sendtime'] : "";
 
         if ($start_sendtime != "" && $end_sendtime != "") {
-            $where[] = ["a.sendtime", 'between', [$start_sendtime, $end_sendtime]];
+            $where[] = ["a.sendtime", 'between', [$start_sendtime." 00:00:00", $end_sendtime." 223:59:59"]];
             $where[] = ["a.status", '>=', 2];//搜索发货时间时,要指定状态为已发货及之后的状态值(0待发货,1待库管发货,2已发货待收货,3已收货,4已全部退货',)
         }
 
@@ -3508,14 +3508,14 @@ class Sale extends Base
                 $datainfo = Db::name('order_out')->insert($data, true);
                 if ($datainfo > 0) {
                     //修改状态,添加待办
-                    ActionLog::logAdd($this->post['token'], [
+                    ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                         "order_code" => $data['outCode'],//出库单号
                         "status" => $data['status'],//这里的status是之前的值
                         "action_remark" => '',//备注
                         "action_type" => "create"//新建create,编辑edit,更改状态status
                     ], "CKD", $data['status'], $data);
 
-                    ProcessOrder::AddProcess($this->post['token'], [
+                    ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                         "order_type" => 'CKD',
                         "order_code" => $data['outCode'],//出库单号
                         "order_id" => $datainfo,
@@ -3612,7 +3612,10 @@ class Sale extends Base
                     "order_type" => 'CKD',
                     "order_code" => $outinfo['outCode'],//出库单号
                     "order_id" => $outinfo['id'],
-                    "order_status" => $outinfo['status'], "before_status" => $old_outinfo_status
+                    "order_status" => $outinfo['status'],
+                    "before_status" => $old_outinfo_status,
+                    'wait_id'=>$outinfo['apply_id'],
+                    'wait_name'=>$outinfo['apply_name'],
                 ]);
                 $orderstatus = $einfo['status'];
                 $einfo['send_num'] += $outinfo['send_num'];
@@ -4187,7 +4190,7 @@ class Sale extends Base
             ->where('status', 1)
             ->where('is_del', 0)
             ->whereIn('outCode', array_column($param['list'], 'outCode'))
-            ->column('id,status,send_num,orderCode,wsm_code', 'outCode');
+            ->column('id,status,send_num,orderCode,wsm_code,apply_id,apply_name', 'outCode');
 
         //处理数据
         Db::startTrans();
@@ -4244,7 +4247,10 @@ class Sale extends Base
                         "order_type" => 'CKD',
                         "order_code" => $value['outCode'],//出库单号
                         "order_id" => $order_out_infos[$value['outCode']]['id'],
-                        "order_status" => 2, "before_status" => $order_out_infos[$value['outCode']]['status']
+                        "order_status" => 2,
+                        "before_status" => $order_out_infos[$value['outCode']]['status'],
+                        'wait_id' => $order_out_infos[$value['outCode']]['apply_id'],
+                        'wait_name' => $order_out_infos[$value['outCode']]['apply_name'],
                     ]);
 
 

+ 11 - 10
app/admin/controller/Salezx.php

@@ -192,25 +192,26 @@ class Salezx extends \app\BaseController
                                 "addtime"=>date("Y-m-d H:i:s"),
                                 "updatetime"=>date("Y-m-d H:i:s")
                             ];
-                           $ou =Db::name("order_out")->insert($out);
+                           $ou =Db::name("order_out")->insertGetId($out);
                            if($ou==false){
                                Db::rollback();
                                return error_show(1002,"咨询订单创建失败");
                            }else{
 
                                //修改状态,添加待办
-                               ActionLog::logAdd($this->post['token'], [
+                               ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                                    "order_code" => $outCode,//出库单号
                                    "status" => $out['status'],//这里的status是之前的值
                                    "action_remark" => '',//备注
                                    "action_type" => "create"//新建create,编辑edit,更改状态status
                                ], "CKD", $out['status'], $out);
 
-                               ProcessOrder::AddProcess($this->post['token'], [
+                               ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                                    "order_type" => 'CKD',
                                    "order_code" => $outCode,//出库单号
-                                   "order_id" => 0,
-                                   "order_status" => $out['status']
+                                   "order_id" => $ou,
+                                   "order_status" => $out['status'],
+                                   'before_status'=>0
                                ]);
 
                                $standing_bood_data['outCode'][]=$outCode;
@@ -224,14 +225,14 @@ class Salezx extends \app\BaseController
                 }
 
                 //修改状态,添加待办
-                ActionLog::logAdd($this->post['token'], [
+                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri], [
                     "order_code" => $orderCode,//销售单code
                     "status" => 0,//这里的status是之前的值
                     "action_remark" => '',//备注
                     "action_type" => "create"//新建create,编辑edit,更改状态status
                 ], "XSQRD", 0, $data);
 
-                ProcessOrder::AddProcess($this->post['token'], [
+                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri], [
                     "order_type" => 'XSQRD',
                     "order_code" => $orderCode,//销售单code
                     "order_id" => $datainfo,
@@ -723,9 +724,9 @@ class Salezx extends \app\BaseController
                     return error_show(1003,"创建失败");
                 }
                 $sio = ["order_code"=>$outCode,"status"=>0,"action_remark"=>'',"action_type"=>"create"];
-                ActionLog::logAdd($this->post['token'],$sio,"CKD",0,$data);
-                $order=["order_type"=>"CKD","order_code"=>$data['outCode'],"order_id"=>$datainfo,"order_status"=>$data['status']];
-                ProcessOrder::AddProcess($this->post['token'],$order);
+                ActionLog::logAdd(['id'=>$rm,'nickname'=>$ri],$sio,"CKD",0,$data);
+                $order=["order_type"=>"CKD","order_code"=>$data['outCode'],"order_id"=>$datainfo,"order_status"=>$data['status'],'before_status'=>0];
+                ProcessOrder::AddProcess(['id'=>$rm,'nickname'=>$ri],$order);
                 $item = $der['status'];
                 $der['send_num']+= $receipt_quantity;
                 $der['wsend_num']-=$receipt_quantity;//($der['send_num'])?$der['wsend_num'] =="" ? $der['send']

+ 32 - 0
app/admin/controller/Stat.php

@@ -345,4 +345,36 @@ FROM
 ");
         return $list;
     }
+
+
+
+    public function saleReport(){
+        $list =Db::name("yuebing_sale")->select()->toArray();
+        $data=[];
+        $temp=["itemName"=>"合计","child"=>[["total_fee"=>round(array_sum(array_column($list,"total_fee"))/10000,2),
+            "num"=>array_sum(array_column($list,"num")),"sale_price"=>'',"good_code"=>'','good_name'=>'',"itemName"=>'']]];
+        foreach ($list as $value){
+            $data[$value['itemid']]['itemName']=$value['itemName'];
+            $value['total_fee'] = round($value['total_fee']/10000,2);
+            $data[$value['itemid']]['child'][]=$value;
+        }
+        array_push($data,$temp);
+        return app_show(0,"获取成功", array_values($data));
+    }
+
+    public function bkReport(){
+        $list =Db::name("yuebing_bk")->select()->toArray();
+        $data=[];
+        $price=["SKU2207141128396667"=>"29.90","SKU2208031050426874"=>"79.00","SKU2208081442447113"=>"79.00","SKU2207141124567141"=>"79.00","SKU2208091004559349"=>"108.00"];
+        $temp=["total"=>round(array_sum(array_column($list,"total"))/10000,2),"num"=>array_sum(array_column($list,"num")),
+            "usable_stock"=>array_sum(array_column($list,"usable_stock")),"sale_price"=>'','good_name'=>'',"spuCode"=>'',"itemName"=>'总计'];
+
+        foreach ($list as &$value){
+            $value['sale_price'] = $price[$value['spuCode']] ??"";
+            $value['total'] = round($value['total']/10000,2);
+        }
+        array_push($list,$temp);
+        return app_show(0,"获取成功",$list);
+    }
+
 }

+ 28 - 0
app/admin/model/ActionProcess.php

@@ -6,7 +6,35 @@ namespace app\admin\model;
 
 use think\Model;
 
+
 class ActionProcess extends Model
 {
 
+    protected $table = 'wsm_action_process';
+    protected $pk = 'id';
+    protected $autoWriteTimestamp = false;
+    protected $hidden = ['order_type', 'order_name', 'pid', 'roleid', 'uid', 'uname', 'weight'];
+
+    public static $action_type_start = 1;//节点类型,1开始节点
+    public static $action_type_process = 2;//节点类型,2过程节点
+    public static $action_type_interrupt = 3;//节点类型,3中断节点
+    public static $action_type_end = 4;//节点类型,4结束节点
+
+
+    public static $operation_type_approval = 1;//操作类型:1审批节点
+    public static $operation_type_system = 2;//操作类型:2系统节点
+
+    public static $status_normal = 1;//状态,1启用
+    public static $status_disable = 0;//状态,0禁用
+
+    public static $is_del_normal = 0;//是否删除,0正常
+    public static $is_deleted = 1;//是否删除,1删除
+
+
+    //数据类型转换
+    public function getStatusAttr($val)
+    {
+        return (string)$val;
+    }
+
 }

+ 27 - 0
app/admin/model/Process.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+//流程表
+class Process extends Model
+{
+    protected $table = 'wsm_process';
+    protected $pk = 'id';
+    protected $autoWriteTimestamp = false;
+
+    public static $is_del_normal = 0;//是否删除,正常
+    public static $is_deleted = 1;//是否删除,已删除
+
+    public static $status_normal = 1;//状态,正常
+    public static $status_disable = 0;//状态,禁用
+
+    //数据类型转换
+    public function getStatusAttr($val)
+    {
+        return (string)$val;
+    }
+
+
+}

+ 4 - 0
app/admin/model/ProcessOrder.php

@@ -38,6 +38,10 @@ class ProcessOrder extends \think\Model
             "addtime"=>date("Y-m-d H:i:s")
         ];
         OrderMsg::addmsg($data);
+
+        //手动排除竞价单ZXD
+        if($order['order_type']!='ZXD') ProcessWait::add($data, isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '');
+
         if(self::insert($data)){
           Workflow::SaveFlow($data);
         };

+ 69 - 3
app/admin/model/ProcessWait.php

@@ -1,12 +1,78 @@
 <?php
 
-
 namespace app\admin\model;
 
+use think\facade\Db;
+use think\Model;
 
-class ProcessWait extends \think\model
+//待办已办
+class ProcessWait extends Model
 {
-   public  static function add($data){
+
+    protected $table = 'wsm_process_wait';
+    protected $pk = 'id';
+    protected $autoWriteTimestamp = false;
+
+    public static $status_wait_handle = 1;//状态,1待处理
+    public static $status_handle_finish = 2;//状态,2待处理
+
+    //添加待办记录
+    public static function add(array $data = [], int $wait_id = 0, string $wait_name = '')
+    {
+//        $data数据格式实例
+//        $data=[
+//            "order_type"=>'',
+//            "order_code"=>'',
+//            "order_id"=>'',
+//            "order_status"=>'',
+//            "action_process"=>'',
+//            "action_status"=>'',
+//            "action_uid"=>'',
+//            "action_name"=>'',
+//            "addtime"=>'',
+//        ];
+
+        //把上一个节点改成已完成
+        Db::name('process_wait')
+            ->where(['order_type' => $data['order_type'], 'order_process' => $data['action_status'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id'], 'status' => self::$status_wait_handle])
+            ->update(['status' => self::$status_handle_finish, 'updatetime' => date('Y-m-d H:i:s')]);
+
+        //查询流程下该节点值的id
+        $id = Db::name('process')
+            ->alias('a')
+            ->join('action_process p', 'p.process_id=a.id AND p.order_process=' . $data['action_process'] . ' AND p.operation_type = ' . ActionProcess::$operation_type_approval)
+            ->where(['a.process_type' => $data['order_type'], 'a.status' => Process::$status_normal, 'a.is_del' => Process::$is_del_normal])->value('p.id', 0);
+
+
+        if ($id) {
+
+            $insert_data = [
+                'order_type' => $data['order_type'],
+                'order_code' => $data['order_code'],
+                'order_id' => $data['order_id'],
+                'action_uid' => $data['action_uid'],
+                'action_name' => $data['action_name'],
+                'status' => self::$status_wait_handle,
+                'order_process' => $data['action_process'],
+                'addtime' => date('Y-m-d H:i:s'),
+                'updatetime' => date('Y-m-d H:i:s'),
+            ];
+
+            if ($wait_id) {
+                $insert_data['wait_id'] = $wait_id;
+                $insert_data['wait_name'] = $wait_name;
+            } else {
+                //查询该节点值对应的角色id
+                $roleid = Db::name('role_process')
+                    ->whereFindInSet('action_data', $id)
+                    ->where('is_del', 0)
+                    ->column('role_id');
+                $insert_data['roleid'] = implode(',', $roleid);
+            }
+
+            //增加新的节点
+            return self::create($insert_data)->save();
+        }
 
     }
 

+ 1 - 1
app/admin/model/Workflow.php

@@ -50,7 +50,7 @@ class Workflow extends \think\Model
             self::insert($proces);
 
         }
-        self::Addwait($data);
+//        self::Addwait($data);
     }
 
     /**

+ 14 - 0
app/admin/route/app.php

@@ -41,6 +41,9 @@ Route::rule('roleinfo', 'admin/Role/RoleInfo');
 Route::rule('roleadd', 'admin/Role/RoleAdd');
 Route::rule('rolesave', 'admin/Role/RoleSave');
 Route::rule('rolestatus', 'admin/Role/RoleStatus');
+Route::rule('role_process_info', 'admin/Role/roleProcessInfo');
+Route::rule('role_process_detail', 'admin/Role/roleProcessDetail');
+Route::rule('role_process_save', 'admin/Role/roleProcessSave');
 
 Route::rule('ulist','admin/Newfill/list');
 Route::rule('add','admin/Newfill/add');
@@ -219,6 +222,15 @@ Route::rule("returnstatus","admin/Purchin/ReturnStatus");
 Route::rule("processlist","admin/Process/list");
 Route::rule("processinfo","admin/Process/info");
 Route::rule("process","admin/Process/process");
+Route::rule('process_get_list','admin/Process/getList');
+Route::rule('process_add','admin/Process/add');
+Route::rule('process_read','admin/Process/read');
+Route::rule('process_update','admin/Process/update');
+Route::rule('action_process_getlist','admin/ActionProcess/getList');
+Route::rule('action_process_add','admin/ActionProcess/add');
+Route::rule('action_process_read','admin/ActionProcess/read');
+Route::rule('action_process_update','admin/ActionProcess/update');
+Route::rule('action_process_all','admin/ActionProcess/getAll');
 
 Route::rule("expresslist","admin/Express/list");
 Route::rule("expressuse","admin/Express/SetUse");
@@ -585,6 +597,8 @@ Route::rule("platprice","admin/CatPlat/PlatPrice");
 Route::rule("catplatall","admin/CatPlat/catlist");
 
 Route::rule('statlist','admin/Stat/list');//
+Route::rule('salereport','admin/Stat/saleReport');//
+Route::rule('bkreport','admin/Stat/bkReport');//
 
 
 Route::rule('standbooklist','admin/StandingBook/getList');//台账列表

+ 5 - 7
app/command/NowReportHandle.php

@@ -459,7 +459,7 @@ class NowReportHandle extends Command
             ->leftJoin("warehouse_info wwi","wwi.wsm_code = wpo.wsm_code")
             ->where('woo.status',">=", 2)
             ->where('a.order_type',"=", 1)
-            ->whereBetween('woo.addtime', [$start, $end])
+            ->whereBetween('woo.sendtime', [$start, $end])
             ->field("wpo.companyNo '业务公司',
                             bkcode '备库单号',
                             woo.orderCode '销售单号',
@@ -736,14 +736,12 @@ ShortText1617865626160 '一级分类',
             ->alias('woo')
             ->leftJoin("sale a", "a.orderCode=woo.orderCode")
             ->leftJoin("order_num won", "won.orderCode=a.orderCode")
-            ->leftJoin("order_back wor", "wor.outCode=woo.outCode and wor.status=4")
-            ->leftJoin("purchease_order wpo", "wpo.cgdNo=won.cgdNo")
-            ->leftJoin("good_basic wgb", "wgb.spuCode=wpo.spuCode")
+            ->leftJoin("order_back wor", "wor.outCode=woo.outCode and wor.status=4 and wor.is_del=0")
+            ->leftJoin("purchease_order wpo", "wpo.cgdNo=won.cgdNo and wpo.is_del=0")
+            ->leftJoin("good_basic wgb", "wgb.spuCode=wpo.spuCode and wgb.is_del=0")
             ->leftJoin("supplier ws", "ws.code=wpo.supplierNo")
             ->leftJoin("warehouse_info wwi", "wwi.wsm_code = wpo.wsm_code")
-            ->where('woo.status', ">=", 2)
-            ->where('a.order_type', "=", 1)
-            ->whereBetween('woo.addtime', [$start, $end])
+            ->where([['woo.status', ">=", 2],['a.order_type', "=", 1],['woo.addtime','between', [$start, $end]]])
             ->field("wpo.companyNo '业务公司',bkcode '备库单号',woo.orderCode '销售单号',woo.outCode '出库单号',wpo.cgdNo '采购单号',wpo.spuCode '商品编号','' as '一级分类','' as '二级分类',wgb.cat_id as '三级分类',wpo.good_name as '商品名称',woo.send_num'出库数量',woo.sendtime '本次出库时间',a.apply_id as '业务部门',a.apply_name as '业务员',wpo.cgder as '采购员',wor.return_num  '出库退货数量',wwi.wsm_type '仓库类型',ws.name '供应商名称',wwi.name '仓库名称'")
             ->cursor();
         $data = [];

+ 8 - 0
app/common.php

@@ -1178,4 +1178,12 @@ if (!function_exists('get_company_name_by_uid')) {
         return $rs;
 
     }
+}
+
+//返回json格式的响应信息,方便中间件记录,目前在abutmenu应用中有用到
+if (!function_exists('json_show')) {
+    function json_show(int $code = 0, string $message = '请求成功', array $data = [])
+    {
+        return json(['code' => $code, 'message' => $message, 'data' => $data]);
+    }
 }

+ 2 - 1
app/youzan/logic/Goodup.php

@@ -168,7 +168,8 @@ class Goodup
                         "order_type" => 'YZSX',
                         "order_code" => $skuCode,
                         "order_id" => $create,
-                        "order_status" => $tmp['exam_status'], "before_status" => $tmp['exam_status']
+                        "order_status" => $tmp['exam_status'],
+                        "before_status" => $tmp['exam_status']
                     ]);
                     $iso = Db::name("good")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->find();
                     if ($iso == false) {