| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 | 
							- <?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; //施工单
 
-     //中文对照
 
-     public $map = [
 
-         self::one => '收货单',
 
-         self::two => '发货单',
 
-         self::three => '采购单',
 
-         self::four => '销售订单',
 
-         self::five => '施工单',
 
-     ];
 
-     const TYPE_ONE = 1;//通过
 
-     const TYPE_TWO = 2;//不通过
 
-     public static $opt_case = [
 
-     ];
 
-     public static $record = [
 
-     ];
 
-     public function checkAll($data,$user){
 
-         if(empty($data['order_number']) || empty($data['opt_case'])) return [false,'必传参数不能为空或者参数值错误!'];
 
-         //具体方法
 
-         $function = self::$opt_case[$data['opt_case']];
 
-         try{
 
-             DB::beginTransaction();
 
-             //更新单据的状态 从待审变成已审核
 
-             list($bool,$msg) = $this->$function($data);
 
-             if(! $bool){
 
-                 DB::rollBack();
 
-                 return [false, $msg];
 
-             }
 
-             DB::commit();
 
-             return [true, ''];
 
-         }catch (\Throwable $exception){
 
-             DB::rollBack();
 
-             return [false, $exception->getMessage()];
 
-         }
 
-     }
 
-     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];
 
-         }
 
-     }
 
- }
 
 
  |