| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 | 
							- <?php
 
- namespace App\Service;
 
- use App\Model\Construction;
 
- use App\Model\ConstructionOrderSub;
 
- use App\Model\InOutRecord;
 
- use App\Model\Inventory;
 
- use App\Model\InventoryInSub;
 
- use App\Model\InventoryOutSub;
 
- use App\Model\MaterialCharge;
 
- use App\Model\MaterialOrder;
 
- use App\Model\MaterialOrderInSub;
 
- use App\Model\MaterialReturn;
 
- use App\Model\RollFilmInventory;
 
- use App\Model\Setting;
 
- use App\Model\Transfer;
 
- use App\Model\TransferInSub;
 
- use App\Model\TransferOutSub;
 
- use App\Model\Warranty;
 
- use App\Service\Oa\OaService;
 
- use Illuminate\Support\Facades\DB;
 
- /**
 
-  * 所有审批相关与流水
 
-  * @package App\Models
 
-  */
 
- class CheckService extends Service
 
- {
 
-     //审批操作对应的数值
 
-     const one = 1; //领料单申领区域审批
 
-     const two = 2; //领料单发货区域审批
 
-     const three = 3; //领料单收货区域审批
 
-     const four = 4; //领料单入库区域审批
 
-     const five = 5; //施工单审核
 
-     const six = 6; //退料单审核
 
-     const seven = 7; //调拨单详情审核
 
-     const eight = 8; //调拨单入库审核
 
-     const nine = 9; //调拨单出库审核
 
-     const ten = 10; //盘点单详情审核
 
-     const eleven = 11; //盘点单入库审核
 
-     const twl = 12; //盘点单出库审核
 
-     const thirteen = 13; //计费领料单审核
 
-     //中文对照
 
-     public $map = [
 
-         self::one => '领料单申领区域审批',
 
-         self::two => '领料单发货区域审批',
 
-         self::three => '领料单收货区域审批',
 
-         self::four => '领料单入库区域审批',
 
-         self::five => '施工单审核',
 
-         self::six => '退料单审核',
 
-         self::seven => '调拨单详情审核',
 
-         self::eight => '调拨单入库审核',
 
-         self::nine => '调拨单出库审核',
 
-         self::ten => '盘点单详情审核',
 
-         self::eleven => '盘点单入库审核',
 
-         self::twl => '盘点单出库审核',
 
-         self::thirteen => '计费领料单审核',
 
-     ];
 
-     const TYPE_ONE = 1;//通过
 
-     const TYPE_TWO = 2;//不通过
 
-     //对应具体单子的具体操作数值(将待审批改为通过或者未审批)
 
-     public static $opt_case = [
 
-         self::one => 'check_material_order_apply',
 
-         self::two => 'check_material_order_send',
 
-         self::three => 'check_material_order_take',
 
-         self::four => 'check_material_order_In',
 
-         self::five => 'check_construction',
 
-         self::six => 'check_material_return',
 
-         self::seven => 'check_transfer_sub',
 
-         self::eight => 'check_transfer_in_sub',
 
-         self::nine => 'check_transfer_out_sub',
 
-         self::ten => 'check_inventory_sub',
 
-         self::eleven => 'check_inventory_in_sub',
 
-         self::twl => 'check_inventory_out_sub',
 
-         self::thirteen => 'check_material_charge',
 
-     ];
 
-     //单子审批通过后产生流水
 
-     public static $record = [
 
-         self::four => 'record_material_order_In',
 
-         self::five => 'record_construction',
 
-         self::six => 'record_material_return',
 
-         self::eight => 'record_transfer_in_sub',
 
-         self::nine => 'record_transfer_out_sub',
 
-         self::eleven => 'record_inventory_in_sub',
 
-         self::twl => 'record_inventory_out_sub',
 
-     ];
 
-     //将状态改为待审核
 
-     public static $opt_case2 = [
 
-         self::one => 'set_status_to_one',
 
-         self::two => 'set_status_to_two',
 
-         self::three => '',
 
-         self::four => '',
 
-         self::five => '',
 
-         self::six => '',
 
-         self::seven => '',
 
-         self::eight => '',
 
-         self::nine => '',
 
-         self::ten => '',
 
-         self::eleven => '',
 
-         self::twl => '',
 
-         self::thirteen => '',
 
-     ];
 
-     //将状态改为待审核
 
-     public function set_status_to_one($data){
 
-         return [true,''];
 
-     }
 
-     /**
 
-      * order_number 单据名称
 
-      * opt_case 审核单据的区域 有已经定义的方法
 
-      */
 
-     public function checkAll($data,$user){
 
-         if(empty($data['order_number']) || empty($data['opt_case']) || ! isset(self::$opt_case2[$data['opt_case']])) return [false,'必传参数不能为空或者参数值错误!'];
 
-         //具体方法
 
-         $function = self::$opt_case2[$data['opt_case']];
 
-         try{
 
-             DB::beginTransaction();
 
-             //更新单据的状态 从待审变成已审核
 
-             list($bool,$msg) = $this->$function($data);
 
-             if(! $bool){
 
-                 DB::rollBack();
 
-                 return [false, $msg];
 
-             }
 
-             //创建审批流
 
-             $args = [
 
-                 'order_no' => $data['order_number'],
 
-                 'menu_id' => $data['menu_id'] ?? 0,
 
-                 'type' => $data['opt_case']
 
-             ];
 
-             $oa = new OaService();
 
-             $bool = $oa->createOaOrder($args);
 
-             DB::commit();
 
-             return [true, ''];
 
-         }catch (\Throwable $exception){
 
-             DB::rollBack();
 
-             return [false, $exception->getMessage()];
 
-         }
 
-     }
 
-     //创建审批流 将状态改为待审核  结束
 
-     //将待审核状态改为审批通过或者驳回
 
-     public function check_status($data){
 
-         return true;
 
-     }
 
-     //产生流水
 
-     public function record_create($data){
 
-         $result = [];
 
-         //写入流水
 
-         InOutRecord::insert($result);
 
-         return true;
 
-     }
 
-     /**
 
-      * 业务单据审核统一入库
 
-      * order_number 订单编号
 
-      * type 1 =》 通过  2  =》 驳回
 
-      * opt_case 具体审核类型 已定义同名静态变量
 
-      */
 
-     public function createRecordAndInventory($data = []){
 
-         if(empty($data['order_number']) || empty($data['type']) || empty($data['opt_case']) || ! isset(self::$opt_case[$data['opt_case']])) return [false,300];
 
-         //具体方法
 
-         $function = self::$opt_case[$data['opt_case']];
 
-         try{
 
-             DB::beginTransaction();
 
-             //更新单据的状态
 
-             $bool = $this->$function($data);
 
-             if($bool && $data['type'] == self::TYPE_ONE && isset(self::$record[$data['opt_case']])){
 
-                 //审批通过 创建流水
 
-                 $function_record = self::$record[$data['opt_case']];
 
-                 $boolean = $this->$function_record($data);
 
-                 if(! $boolean) { //创建流水失败 数据库回滚
 
-                     DB::rollBack();
 
-                     return [false, 300];
 
-                 }
 
-                 //更新库存
 
-                 $inventory = new InventoryService();
 
-                 $boole = $inventory->changeInventory($data);
 
-                 if(! $boole){
 
-                     DB::rollBack();
 
-                     return [false, 300];
 
-                 }
 
-             }
 
-             DB::commit();
 
-             return [true, 200];
 
-         }catch (\Throwable $exception){
 
-             DB::rollBack();
 
-             return [false, 201];
 
-         }
 
-     }
 
- }
 
 
  |