|
@@ -4,6 +4,7 @@ namespace App\Service;
|
|
|
|
|
|
use App\Jobs\ProcessDataJob;
|
|
|
use App\Model\PurchaseOrder;
|
|
|
+use App\Model\Setting;
|
|
|
use App\Model\U8Job;
|
|
|
|
|
|
class DataSyncToU8Service extends Service
|
|
@@ -43,4 +44,50 @@ class DataSyncToU8Service extends Service
|
|
|
|
|
|
return [true, ''];
|
|
|
}
|
|
|
+
|
|
|
+ public function snListAccording($data,$user){
|
|
|
+ //特殊的门店
|
|
|
+ $setting = Setting::where('setting_name','bt_top_depart_id')->first();
|
|
|
+ $bt_top_depart_id = $setting['setting_value'] ?? [];
|
|
|
+ $bt_top_depart_id = json_decode($bt_top_depart_id,true);
|
|
|
+
|
|
|
+ //当前门店
|
|
|
+ $current_top_depart_id = $user['depart_top'][0] ?? [];
|
|
|
+ $current_top_depart_id = $current_top_depart_id['depart_id'] ?? 0;
|
|
|
+
|
|
|
+ if(in_array($current_top_depart_id, $bt_top_depart_id)){
|
|
|
+ //总社 直接读取sn码表
|
|
|
+ $sn_type = 1;//总社
|
|
|
+ }else{
|
|
|
+ $sn_type = 2;//分社
|
|
|
+ //发货单 sn码
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, 'sn_type' => $sn_type];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnFromU8($data, $user){
|
|
|
+ if(empty($data['sn_type'])) return [false, 'sn码来源依据不能为空'];
|
|
|
+ if(empty($data['code'])) return [false, '产品编码不能为空'];
|
|
|
+ list($status,$return) = $this->getSnList($data, $user);
|
|
|
+ return [$status, $return];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSnList($data, $user){
|
|
|
+ $header = ['Content-Type:application/json'];
|
|
|
+ $post = [
|
|
|
+ 'urlFromT9' => 'getSnList',
|
|
|
+ 'code' => $data['code'],
|
|
|
+ 'sn' => $data['sn'] ?? "",
|
|
|
+ 'sn_type' => $data['sn_type'],
|
|
|
+ 'depart_title' => $this->getMyTopDepart($user,true),
|
|
|
+ 'page_size' => $data['page_size'] ?? 10,
|
|
|
+ 'page_index' => $data['page_index'] ?? 1,
|
|
|
+ ];
|
|
|
+ $post = json_encode($post);
|
|
|
+ list($status, $msg) = $this->post_helper("https://workapi.qingyaokeji.com/api/getSnList", $post, $header);
|
|
|
+ if($msg['code'] != 200) return [false, $msg['msg']];
|
|
|
+
|
|
|
+ return [true, $msg['data'] ?? []];
|
|
|
+ }
|
|
|
}
|