|
@@ -24,7 +24,7 @@ class TestService extends Service
|
|
|
$json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',$json);
|
|
$json = str_replace('"workflowSearchBean":[]','"workflowSearchBean":{}',$json);
|
|
|
$json = str_replace('"loginBindingParameters":[]','"loginBindingParameters":{}',$json);
|
|
$json = str_replace('"loginBindingParameters":[]','"loginBindingParameters":{}',$json);
|
|
|
|
|
|
|
|
- list($status, $result) = $this->post_helper($url,$json, $header, 40);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url,$json, $header, 40,'LFMY');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
|
|
|
|
|
return [true, $result];
|
|
return [true, $result];
|
|
@@ -67,367 +67,6 @@ class TestService extends Service
|
|
|
return [true, $result];
|
|
return [true, $result];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function updateTopStock($data){
|
|
|
|
|
- list($status, $msg) = $this->rule();
|
|
|
|
|
-// if(! $status) return [false, 'IP未入白名单'];
|
|
|
|
|
- if(empty($data['urlFromT9']) || $data['urlFromT9'] != "getStock") return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['code'])) return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['warehouse'])) return [false,'API请求参数不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- list($status, $msg) = $this->connectYy();
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
-
|
|
|
|
|
- //数据库
|
|
|
|
|
- $db = $msg[0];
|
|
|
|
|
- $u8 = $msg[1];
|
|
|
|
|
- list($status, $msg) = $this->getStock($db, $u8,$data['code'],$data['warehouse']);
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnList($data){
|
|
|
|
|
- list($status, $msg) = $this->rule();
|
|
|
|
|
-// if(! $status) return [false, 'IP未入白名单'];
|
|
|
|
|
- if(empty($data['urlFromT9']) || $data['urlFromT9'] != "getSnList") return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['sn_type'])) return [false, 'sn码来源依据不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- list($status, $msg) = $this->connectYy();
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
-
|
|
|
|
|
- //数据库
|
|
|
|
|
- $db = $msg[0];
|
|
|
|
|
- $u8 = $msg[1];
|
|
|
|
|
- if($data['sn_type'] == 1){
|
|
|
|
|
- list($status, $msg) = $this->getSnListFormU8One($db, $u8,$data);
|
|
|
|
|
- }else{
|
|
|
|
|
- //发货出库单 sn码
|
|
|
|
|
- list($status, $msg) = $this->getSnListFormU8Two($db, $u8,$data);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnforMap($data){
|
|
|
|
|
- list($status, $msg) = $this->rule();
|
|
|
|
|
-// if(! $status) return [false, 'IP未入白名单'];
|
|
|
|
|
- if(empty($data['urlFromT9']) || $data['urlFromT9'] != "getSnMap") return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['sn'])) return [false, 'sn码不能为空'];
|
|
|
|
|
- if(empty($data['code'])) return [false, '产品编码不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- list($status, $msg) = $this->connectYy();
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
-
|
|
|
|
|
- //数据库
|
|
|
|
|
- $db = $msg[0];
|
|
|
|
|
- $u8 = $msg[1];
|
|
|
|
|
- list($status, $msg) = $this->getSnListFormU8ForMap($db, $u8,$data);
|
|
|
|
|
-
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnForWarranty($data){
|
|
|
|
|
- list($status, $msg) = $this->rule();
|
|
|
|
|
-// if(! $status) return [false, 'IP未入白名单'];
|
|
|
|
|
- if(empty($data['urlFromT9']) || $data['urlFromT9'] != "getSnForWarranty") return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['sn'])) return [false, 'sn码不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- list($status, $msg) = $this->connectYy();
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
-
|
|
|
|
|
- //数据库
|
|
|
|
|
- $db = $msg[0];
|
|
|
|
|
- $u8 = $msg[1];
|
|
|
|
|
- list($status, $msg) = $this->getSnForWarrantyData($db, $u8,$data);
|
|
|
|
|
-
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function rule(){
|
|
|
|
|
- // 获取用户的IP地址
|
|
|
|
|
- $userIP = $_SERVER['REMOTE_ADDR'];
|
|
|
|
|
- // 获取设置的IP地址
|
|
|
|
|
- $ip = env("AliYUN");
|
|
|
|
|
- $allowedIPs = [$ip];
|
|
|
|
|
- $allowedIPs = array_filter($allowedIPs);
|
|
|
|
|
-
|
|
|
|
|
- if(empty($allowedIPs)) return [false, $userIP];
|
|
|
|
|
- // 校验用户IP是否在允许的范围内
|
|
|
|
|
- $isValidIP = false;
|
|
|
|
|
- foreach ($allowedIPs as $allowedIP) {
|
|
|
|
|
- if (strpos($allowedIP, '/') !== false) {
|
|
|
|
|
- // IP段表示法校验
|
|
|
|
|
- list($subnet, $mask) = explode('/', $allowedIP);
|
|
|
|
|
- if ((ip2long($userIP) & ~((1 << (32 - $mask)) - 1)) == ip2long($subnet)) {
|
|
|
|
|
- $isValidIP = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 单个IP地址校验
|
|
|
|
|
- if ($allowedIP === $userIP) {
|
|
|
|
|
- $isValidIP = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [$isValidIP, $userIP];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function connectYy(){
|
|
|
|
|
- $model_box = DB::connection("mysqlT9");
|
|
|
|
|
- $u8 = $model_box->table('setting')
|
|
|
|
|
- ->where('setting_name','u8')
|
|
|
|
|
- ->where('setting_value','<>','')
|
|
|
|
|
- ->first();
|
|
|
|
|
- if(empty($u8)) return [false, 'u8配置参数不存在!'];
|
|
|
|
|
-
|
|
|
|
|
- $u8 = $u8->setting_value;
|
|
|
|
|
- // 使用 eval() 函数执行字符串并转换为数组
|
|
|
|
|
- $u8 = eval("return {$u8};");
|
|
|
|
|
- if(empty($u8['domain'])) return [false, '外部域名不能为空!'];
|
|
|
|
|
- if(empty($u8['u8_api_port'])) return [false, 'u8程序API端口不能为空!'];
|
|
|
|
|
- if(empty($u8['u8_database_port'])) return [false, 'u8程序数据库端口不能为空!'];
|
|
|
|
|
- if(empty($u8['database'])) return [false, 'u8程序数据库不能为空!'];
|
|
|
|
|
- if(empty($u8['database_account'])) return [false, 'u8程序数据库登录账号不能为空!'];
|
|
|
|
|
- if(empty($u8['database_password'])) return [false, 'u8程序数据库登录密码不能为空!'];
|
|
|
|
|
- if(empty($u8['sAccID'])) return [false, 'u8程序sAccID不能为空!'];
|
|
|
|
|
- if(empty($u8['sServer'])) return [false, 'u8程序sServer不能为空!'];
|
|
|
|
|
- if(empty($u8['sUserID'])) return [false, 'u8程序sUserID不能为空!'];
|
|
|
|
|
- if(empty($u8['sPassword'])) return [false, 'u8程序sPassword不能为空!'];
|
|
|
|
|
-
|
|
|
|
|
- $config = [
|
|
|
|
|
- 'driver' => 'sqlsrv',
|
|
|
|
|
- 'host' => $u8['domain'],
|
|
|
|
|
- 'port' => $u8['u8_database_port'],
|
|
|
|
|
- 'database' => $u8['database'],
|
|
|
|
|
- 'username' => $u8['database_account'],
|
|
|
|
|
- 'password' => $u8['database_password'],
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- // 数据库配置设置
|
|
|
|
|
- Config::set('database.connections.sqlsrvs', $config);
|
|
|
|
|
-
|
|
|
|
|
- // 连接
|
|
|
|
|
- try {
|
|
|
|
|
- $pdo = DB::connection('sqlsrvs')->getPdo();
|
|
|
|
|
- if ($pdo instanceof \PDO) {
|
|
|
|
|
- // 连接成功的逻辑代码
|
|
|
|
|
- $db = DB::connection('sqlsrvs');
|
|
|
|
|
- return [true, [$db, $u8]];
|
|
|
|
|
- } else {
|
|
|
|
|
- return [false, '连接失败!'];
|
|
|
|
|
- }
|
|
|
|
|
- } catch (\Throwable $e) {
|
|
|
|
|
- return [false, $e->getMessage()];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getStock($db, $u8, $code = [], $warehouse = ""){
|
|
|
|
|
- if(empty($code) || empty($warehouse)) return [false, '存货以及仓库不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- //映射ip是否通畅
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-
|
|
|
|
|
- $result = $db->table('CurrentStock')
|
|
|
|
|
- ->where("cWhCode", $warehouse)
|
|
|
|
|
- ->whereIn("cInvCode", $code)
|
|
|
|
|
- ->select('iQuantity as number', 'cInvCode as product_no')
|
|
|
|
|
- ->get()->toArray();
|
|
|
|
|
- $return = [];
|
|
|
|
|
- foreach ($result as $value){
|
|
|
|
|
- $return[] = [
|
|
|
|
|
- 'number' => floatval($value->number),
|
|
|
|
|
- 'product_no' => $value->product_no
|
|
|
|
|
- ];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [true, $return];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnListFormU8One($db, $u8, $data){
|
|
|
|
|
- if(empty($data['code'])) return [false, '存货不能为空'];
|
|
|
|
|
- $sn = $data['sn'] ?? "";
|
|
|
|
|
- $construction_id = $data['construction_id'] ?? 0;
|
|
|
|
|
- $warehouse = [
|
|
|
|
|
- '001',
|
|
|
|
|
- '003',
|
|
|
|
|
- '010',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- //映射ip是否通畅
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-// $db->enableQueryLog();
|
|
|
|
|
-
|
|
|
|
|
- //检索条件 在库的
|
|
|
|
|
- $model = $db->table('ST_SNState')
|
|
|
|
|
- ->select('cinvCode as code','cInvSN as sn','AutoID as auto_id')
|
|
|
|
|
- ->whereIn("cWhCode", $warehouse)
|
|
|
|
|
- ->where("cInvCode", $data['code'])
|
|
|
|
|
- ->where("iSNState", 2)
|
|
|
|
|
- ->when(! empty($sn), function ($query) use ($sn) {
|
|
|
|
|
- return $query->where('cInvSN', 'LIKE', '%'.$sn.'%');
|
|
|
|
|
- })
|
|
|
|
|
-// ->when(! empty($construction_id), function ($query) use ($construction_id) {
|
|
|
|
|
-// return $query->whereNull('cSNDefine1')->orWhere('cSNDefine1', '')->orWhere('cSNDefine1', $construction_id);
|
|
|
|
|
-// })
|
|
|
|
|
- ->when(empty($construction_id), function ($query) {
|
|
|
|
|
- return $query->where(function ($q) {
|
|
|
|
|
- $q->whereNull('cSNDefine1')
|
|
|
|
|
- ->orWhere('cSNDefine1', '');
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- ->orderBy('cSNDefine1','desc')
|
|
|
|
|
- ->orderBy('AutoID','asc');
|
|
|
|
|
-
|
|
|
|
|
- $list = $this->limit($model, '', $data);
|
|
|
|
|
-// dd($db->getQueryLog());
|
|
|
|
|
-
|
|
|
|
|
- return [true, $list];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnListFormU8Two($db, $u8, $data){
|
|
|
|
|
- if(empty($data['code']) || empty($data['depart_title'])) return [false, '存货以及门店信息不能为空'];
|
|
|
|
|
- $sn = $data['sn'] ?? "";
|
|
|
|
|
- $construction_id = $data['construction_id'] ?? 0;
|
|
|
|
|
-// $db->enableQueryLog();
|
|
|
|
|
-
|
|
|
|
|
- //映射ip是否通畅
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-
|
|
|
|
|
- $model = $db->table('rdrecord32 as a')
|
|
|
|
|
- ->leftJoin('rdrecords32 as b','b.ID','a.ID')
|
|
|
|
|
- ->leftJoin('ST_SNDetail_SaleOut as c','c.iVouchsID','b.AutoID')
|
|
|
|
|
- ->select("c.cInvCode as code",'c.cinvSN as sn','c.AutoID as auto_id') //,'c.cSNDefine1','a.ID'
|
|
|
|
|
- ->whereNotNull('a.cHandler')
|
|
|
|
|
- ->where("b.cInvCode", $data['code'])
|
|
|
|
|
- ->where("b.iQuantity", '>', 0)
|
|
|
|
|
- ->where("b.cDefine31", $data['depart_title'])
|
|
|
|
|
- ->whereNotNull("c.cinvSN")
|
|
|
|
|
- ->when(! empty($sn), function ($query) use ($sn) {
|
|
|
|
|
- return $query->where('c.cInvSN', 'LIKE', '%'.$sn.'%');
|
|
|
|
|
- })
|
|
|
|
|
-// ->when(! empty($construction_id), function ($query) use ($construction_id) {
|
|
|
|
|
-// return $query->whereNull('c.cSNDefine1')->orWhere('c.cSNDefine1', '')->orWhere('c.cSNDefine1', $construction_id);
|
|
|
|
|
-// })
|
|
|
|
|
- ->when(empty($construction_id), function ($query) {
|
|
|
|
|
- return $query->where(function ($q) {
|
|
|
|
|
- $q->whereNull('c.cSNDefine1')
|
|
|
|
|
- ->orWhere('c.cSNDefine1', '');
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
- ->orderBy('c.cSNDefine1','desc')
|
|
|
|
|
- ->orderBy('a.ID','desc')
|
|
|
|
|
- ->orderBy('c.AutoID','asc');
|
|
|
|
|
-
|
|
|
|
|
- $list = $this->limit($model, '', $data);
|
|
|
|
|
-// $logs = $db->getQueryLog();dd($logs);
|
|
|
|
|
-
|
|
|
|
|
- return [true, $list];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnListFormU8ForMap($db, $u8, $data){
|
|
|
|
|
- //映射ip是否通畅
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-
|
|
|
|
|
- $warehouse = [
|
|
|
|
|
- '001',
|
|
|
|
|
- '003',
|
|
|
|
|
- '010',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- $list = $db->table('ST_SNState')
|
|
|
|
|
- ->select("cInvCode as code",'cinvSN as sn')
|
|
|
|
|
- ->whereIn("cWhCode", $warehouse)
|
|
|
|
|
- ->whereIn("cInvCode", $data['code'])
|
|
|
|
|
- ->whereIn('cInvSN', $data['sn'])
|
|
|
|
|
-// ->where("iSNState", 2)
|
|
|
|
|
- ->get()->toArray();
|
|
|
|
|
-
|
|
|
|
|
- return [true, $list];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function getSnForWarrantyData($db, $u8, $data){
|
|
|
|
|
- //映射ip是否通畅
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-
|
|
|
|
|
- $warehouse = [
|
|
|
|
|
- '001',
|
|
|
|
|
- '003',
|
|
|
|
|
- '010',
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- $list = $db->table('ST_SNState')
|
|
|
|
|
- ->select("cInvCode as code",'cinvSN as sn','AutoID as auto_id')
|
|
|
|
|
- ->whereIn("cWhCode", $warehouse)
|
|
|
|
|
- ->where('cInvSN', $data['sn'])
|
|
|
|
|
-// ->where("iSNState", 2)
|
|
|
|
|
- ->first();
|
|
|
|
|
-
|
|
|
|
|
- return [true, $list];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function saveSnUseData($data){
|
|
|
|
|
- list($status, $msg) = $this->rule();
|
|
|
|
|
-// if(! $status) return [false, 'IP未入白名单'];
|
|
|
|
|
- if(empty($data['urlFromT9']) || $data['urlFromT9'] != "saveSnUseData") return [false,'API请求参数不能为空'];
|
|
|
|
|
- if(empty($data['sn_type'])) return [false,'sn码来源依据不能为空'];
|
|
|
|
|
-// if(empty($data['sn_for_u8'])) return [false, 'sn码更新信息不能为空'];
|
|
|
|
|
- if(empty($data['data_id'])) return [false, 'dataID信息不能为空'];
|
|
|
|
|
-
|
|
|
|
|
- list($status, $msg) = $this->connectYy();
|
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
-
|
|
|
|
|
- //数据库
|
|
|
|
|
- $db = $msg[0];
|
|
|
|
|
- $u8 = $msg[1];
|
|
|
|
|
- list($status, $msg) = $this->saveSnUseDataDetail($db, $u8,$data);
|
|
|
|
|
-
|
|
|
|
|
- return [$status, $msg];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function saveSnUseDataDetail($db, $u8, $data){
|
|
|
|
|
- //映射ip是否通畅 data_id = 1
|
|
|
|
|
- $bool = $this->isDomainAvailable($u8['domain']);
|
|
|
|
|
- if(! $bool) return [false, 'U8程序外部域名不可达'];
|
|
|
|
|
-
|
|
|
|
|
- $sn_for_u8 = $data['sn_for_u8'] ?? [];
|
|
|
|
|
- try {
|
|
|
|
|
- DB::beginTransaction();
|
|
|
|
|
- if(empty($sn_for_u8)){//删除
|
|
|
|
|
- if($data['sn_type'] == 1){
|
|
|
|
|
- $db->table('ST_SNState')
|
|
|
|
|
- ->where('cSNDefine1', $data['data_id'])
|
|
|
|
|
- ->update(['cSNDefine1' => ""]);
|
|
|
|
|
- }else{
|
|
|
|
|
- $db->table('ST_SNDetail_SaleOut')
|
|
|
|
|
- ->where('cSNDefine1', $data['data_id'])
|
|
|
|
|
- ->update(['cSNDefine1' => ""]);
|
|
|
|
|
- }
|
|
|
|
|
- }else{//增加或更新
|
|
|
|
|
- if($data['sn_type'] == 1){
|
|
|
|
|
- $db->table('ST_SNState')
|
|
|
|
|
- ->whereIn('AutoID', $sn_for_u8)
|
|
|
|
|
- ->update(['cSNDefine1' => $data['data_id']]);
|
|
|
|
|
- }else{
|
|
|
|
|
- $db->table('ST_SNDetail_SaleOut')
|
|
|
|
|
- ->whereIn('AutoID', $sn_for_u8)
|
|
|
|
|
- ->update(['cSNDefine1' => $data['data_id']]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- DB::commit();
|
|
|
|
|
- }catch (\Exception $exception){
|
|
|
|
|
- DB::rollBack();
|
|
|
|
|
- return [false, $exception->getMessage()];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return [true, ''];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
//-----------------------------------朗峰u8-----
|
|
//-----------------------------------朗峰u8-----
|
|
|
public function getToken($common_array){
|
|
public function getToken($common_array){
|
|
|
list($status, $msg) = $this->SetU8($common_array);
|
|
list($status, $msg) = $this->SetU8($common_array);
|
|
@@ -445,7 +84,7 @@ class TestService extends Service
|
|
|
"bPersist"=> true
|
|
"bPersist"=> true
|
|
|
];
|
|
];
|
|
|
$header = ['Content-Type:application/json'];
|
|
$header = ['Content-Type:application/json'];
|
|
|
- list($status, $result) = $this->post_helper($url,json_encode($json), $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url,json_encode($json), $header, 30, $common_array['title'] . "获取token");
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
if(! isset($result['code'])) return [false, '获取用友登录信息失败,请重新操作'];
|
|
if(! isset($result['code'])) return [false, '获取用友登录信息失败,请重新操作'];
|
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
@@ -488,7 +127,7 @@ class TestService extends Service
|
|
|
];
|
|
];
|
|
|
$json = json_encode($json);
|
|
$json = json_encode($json);
|
|
|
|
|
|
|
|
- list($status, $result) = $this->post_helper($url,$json, $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url,$json, $header, 30, $common_array['title'] . '获取销售订单');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
|
|
|
|
|
if(! isset($result['code'])) return [false, '拉取销售订单失败,请重新拉取'];
|
|
if(! isset($result['code'])) return [false, '拉取销售订单失败,请重新拉取'];
|
|
@@ -496,16 +135,18 @@ class TestService extends Service
|
|
|
if(empty($result['data'])) return [true, []];
|
|
if(empty($result['data'])) return [true, []];
|
|
|
|
|
|
|
|
$r_data = $result['data'];
|
|
$r_data = $result['data'];
|
|
|
- $return = $this->returnOrders($common_array['site'], $r_data, $msg);
|
|
|
|
|
|
|
+ $return = $this->returnOrders($common_array, $r_data, $msg);
|
|
|
|
|
|
|
|
return [true, $return];
|
|
return [true, $return];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function returnOrders($site, $r_data, $msg){
|
|
|
|
|
|
|
+ private function returnOrders($common_array, $r_data, $msg){
|
|
|
|
|
+ $site = $common_array['site'];
|
|
|
|
|
+ $title = $common_array['title'];
|
|
|
$return = [];
|
|
$return = [];
|
|
|
if($site == 'LFMY'){
|
|
if($site == 'LFMY'){
|
|
|
foreach ($r_data as $value){
|
|
foreach ($r_data as $value){
|
|
|
- list($status, $detail) = $this->getSalesDetail($value, $msg);
|
|
|
|
|
|
|
+ list($status, $detail) = $this->getSalesDetail($value, $msg, $title);
|
|
|
if(! $status) return [false, $detail];
|
|
if(! $status) return [false, $detail];
|
|
|
$return_detail = [];
|
|
$return_detail = [];
|
|
|
$total_qty = $money = 0;
|
|
$total_qty = $money = 0;
|
|
@@ -551,7 +192,7 @@ class TestService extends Service
|
|
|
}
|
|
}
|
|
|
}elseif ($site == 'HCLT'){
|
|
}elseif ($site == 'HCLT'){
|
|
|
foreach ($r_data as $value){
|
|
foreach ($r_data as $value){
|
|
|
- list($status, $detail) = $this->getSalesDetail($value, $msg);
|
|
|
|
|
|
|
+ list($status, $detail) = $this->getSalesDetail($value, $msg, $title);
|
|
|
if(! $status) return [false, $detail];
|
|
if(! $status) return [false, $detail];
|
|
|
$return_detail = [];
|
|
$return_detail = [];
|
|
|
$total_qty = $money = 0;
|
|
$total_qty = $money = 0;
|
|
@@ -597,7 +238,7 @@ class TestService extends Service
|
|
|
}
|
|
}
|
|
|
}elseif ($site == 'JLWM'){
|
|
}elseif ($site == 'JLWM'){
|
|
|
foreach ($r_data as $value){
|
|
foreach ($r_data as $value){
|
|
|
- list($status, $detail) = $this->getSalesDetail($value, $msg);
|
|
|
|
|
|
|
+ list($status, $detail) = $this->getSalesDetail($value, $msg, $title);
|
|
|
if(! $status) return [false, $detail];
|
|
if(! $status) return [false, $detail];
|
|
|
$return_detail = [];
|
|
$return_detail = [];
|
|
|
$total_qty = $money = 0;
|
|
$total_qty = $money = 0;
|
|
@@ -660,7 +301,7 @@ class TestService extends Service
|
|
|
return [true, $host];
|
|
return [true, $host];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function getSalesDetail($sale_order, $msg){
|
|
|
|
|
|
|
+ private function getSalesDetail($sale_order, $msg, $title){
|
|
|
list($host, $token) = $msg;
|
|
list($host, $token) = $msg;
|
|
|
|
|
|
|
|
$header = ["Authorization: {$token}",'Content-Type:application/json'];;
|
|
$header = ["Authorization: {$token}",'Content-Type:application/json'];;
|
|
@@ -672,7 +313,7 @@ class TestService extends Service
|
|
|
"@code"=> $sale_order["csocode"]
|
|
"@code"=> $sale_order["csocode"]
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
- list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30, $title . '获取销售订单详情');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
if(! isset($result['code'])) return [false, '拉取销售订单详情失败,请重新拉取'];
|
|
if(! isset($result['code'])) return [false, '拉取销售订单详情失败,请重新拉取'];
|
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
@@ -685,6 +326,7 @@ class TestService extends Service
|
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
|
list($host, $token) = $msg;
|
|
list($host, $token) = $msg;
|
|
|
|
|
|
|
|
|
|
+ $title = $common_array['title'];
|
|
|
if(empty($data['iHead'])) return [false, '领料单表头信息不能为空'];
|
|
if(empty($data['iHead'])) return [false, '领料单表头信息不能为空'];
|
|
|
if(empty($data['iBody'])) return [false, '领料单表体信息不能为空'];
|
|
if(empty($data['iBody'])) return [false, '领料单表体信息不能为空'];
|
|
|
|
|
|
|
@@ -699,7 +341,7 @@ class TestService extends Service
|
|
|
];
|
|
];
|
|
|
$json_str = json_encode($json);
|
|
$json_str = json_encode($json);
|
|
|
|
|
|
|
|
- list($status, $result) = $this->post_helper($url, $json_str, $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url, $json_str, $header, 30, $title . '生成领料申请单');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
if(! isset($result['code'])) return [false, '生成领料申请单失败,请重新操作'];
|
|
if(! isset($result['code'])) return [false, '生成领料申请单失败,请重新操作'];
|
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
@@ -712,6 +354,7 @@ class TestService extends Service
|
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
|
list($host, $token) = $msg;
|
|
list($host, $token) = $msg;
|
|
|
|
|
|
|
|
|
|
+ $title = $common_array['title'];
|
|
|
if(empty($data['iHead'])) return [false, '产成品入库单单表头信息不能为空'];
|
|
if(empty($data['iHead'])) return [false, '产成品入库单单表头信息不能为空'];
|
|
|
if(empty($data['iBody'])) return [false, '产成品入库单表体信息不能为空'];
|
|
if(empty($data['iBody'])) return [false, '产成品入库单表体信息不能为空'];
|
|
|
|
|
|
|
@@ -725,7 +368,7 @@ class TestService extends Service
|
|
|
],
|
|
],
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30, $title . '生成产成品入库单');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
if(! isset($result['code'])) return [false, '生成产成品入库单失败,请重新操作'];
|
|
if(! isset($result['code'])) return [false, '生成产成品入库单失败,请重新操作'];
|
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
@@ -738,6 +381,8 @@ class TestService extends Service
|
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
|
list($host, $token) = $msg;
|
|
list($host, $token) = $msg;
|
|
|
|
|
|
|
|
|
|
+ $title = $common_array['title'];
|
|
|
|
|
+
|
|
|
if(empty($data['iHead'])) return [false, '发货单单表头信息不能为空'];
|
|
if(empty($data['iHead'])) return [false, '发货单单表头信息不能为空'];
|
|
|
if(empty($data['iBody'])) return [false, '发货单表体信息不能为空'];
|
|
if(empty($data['iBody'])) return [false, '发货单表体信息不能为空'];
|
|
|
|
|
|
|
@@ -755,7 +400,7 @@ class TestService extends Service
|
|
|
]
|
|
]
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30);
|
|
|
|
|
|
|
+ list($status, $result) = $this->post_helper($url, json_encode($json), $header, 30, $title . '生成发货单');
|
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
if(! isset($result['code'])) return [false, '生成发货单失败,请重新操作'];
|
|
if(! isset($result['code'])) return [false, '生成发货单失败,请重新操作'];
|
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
if($result['code'] != 0) return [false, $result['msg']];
|
|
@@ -834,8 +479,8 @@ class TestService extends Service
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------朗峰u8-----
|
|
//-----------------------------------朗峰u8-----
|
|
|
- public function post_helper($url, $data, $header = [], $timeout = 20){
|
|
|
|
|
- Log::channel('apiLog')->info('朗峰POST', ["api" => $url , "param" => $data ,"header" => $header]);
|
|
|
|
|
|
|
+ public function post_helper($url, $data, $header = [], $timeout = 20, $title = ""){
|
|
|
|
|
+ Log::channel('apiLog')->info($title . 'POST', ["api" => $url , "param" => $data ,"header" => $header]);
|
|
|
|
|
|
|
|
$ch = curl_init();
|
|
$ch = curl_init();
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
@@ -857,12 +502,12 @@ class TestService extends Service
|
|
|
$errorMessage = curl_error($ch);
|
|
$errorMessage = curl_error($ch);
|
|
|
$message = "cURL Error #{$errorNumber}: {$errorMessage}";
|
|
$message = "cURL Error #{$errorNumber}: {$errorMessage}";
|
|
|
|
|
|
|
|
- Log::channel('apiLog')->info('朗峰POST结果', ["message" => $message ]);
|
|
|
|
|
|
|
+ Log::channel('apiLog')->info($title . 'POST结果', ["message" => $message ]);
|
|
|
return [false, $message];
|
|
return [false, $message];
|
|
|
}
|
|
}
|
|
|
curl_close($ch);
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
- Log::channel('apiLog')->info('朗峰POST结果', ["message" => json_decode($r, true) ]);
|
|
|
|
|
|
|
+ Log::channel('apiLog')->info($title . 'POST结果', ["message" => json_decode($r, true) ]);
|
|
|
return [true, json_decode($r, true)];
|
|
return [true, json_decode($r, true)];
|
|
|
}
|
|
}
|
|
|
|
|
|