|
@@ -0,0 +1,452 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * 系统自动处理在途库存的香港问题
|
|
|
+ */
|
|
|
+class Model_logic_u9zt extends Lin_Model {
|
|
|
+ public $xczzcode = '130';//许昌销售公司编码
|
|
|
+ public $xccp_code = '13001';//许昌成品库的编码
|
|
|
+ public $xgzzcode = '140';//香港组织公司编码
|
|
|
+ public $xgzt_code = '14001';//香港在途库的编码
|
|
|
+ public $xgmc_code = '14002';//香港美仓的编码
|
|
|
+ public $ztcode = '9966';//账套的code;
|
|
|
+ public $tb_org_arr =[140];//同步组织
|
|
|
+ public $gys = "98002";//供应商 98001 龙盈 98002 龙熠
|
|
|
+ public $yyid = "98003";
|
|
|
+ //切记要修改token_120的token真正的token!!!!
|
|
|
+ function __construct(){
|
|
|
+ parent::__construct();
|
|
|
+ $this->load->_model('Model_settingtest','settingtest');
|
|
|
+ $this->load->_model("Model_apiyyv1",'apiyyv1');
|
|
|
+ $this->load->_model('Model_classid','classid');
|
|
|
+ $this->load->_model('Model_typeclass','typeclass');
|
|
|
+ $this->load->_model('Model_shop','shop');
|
|
|
+ $this->load->_model('Model_zzquque_u9','zzquque_u9');
|
|
|
+ $this->load->_model('Model_zzququeu9_logs','zzququeu9_logs');
|
|
|
+ $this->load->_model('Model_logic_tools','logic_tools');
|
|
|
+ $this->load->_model('Model_logic_u9tools','logic_u9tools');
|
|
|
+ $this->load->_model("Model_logic_order","logic_order");
|
|
|
+ $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
|
|
|
+ }
|
|
|
+ public function getToken($type){
|
|
|
+ $name = "get_yytoken_".$type;
|
|
|
+ $token = $this->settingtest->$name();
|
|
|
+ return $token;
|
|
|
+ }
|
|
|
+ //转码准备数据
|
|
|
+ public function transPrepare(){
|
|
|
+ $classid = $this->classid->sku();
|
|
|
+ $tcall = $this->typeclass->find_all();
|
|
|
+ foreach ($tcall as $v)
|
|
|
+ {
|
|
|
+ $tcjm[$v['id']] = array($v['jm'],$v['classid']);
|
|
|
+ $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
|
|
|
+ }
|
|
|
+ return [
|
|
|
+ 'classid'=>$classid,
|
|
|
+ 'typeclass'=>$typeclass,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //创建调出单
|
|
|
+ public function createdDc($info,$classid,$typeclass){
|
|
|
+
|
|
|
+ $list = $this->whlabeltransport->find_all("order_no = '".$info['order_no']."'");
|
|
|
+ $do_flag = true;
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ if($v['cz'] ==1 ){
|
|
|
+ $do_flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!$do_flag){
|
|
|
+ $this->editData($info['id'],[
|
|
|
+ 'dc_status'=>-1,
|
|
|
+ 'update_time'=>time()
|
|
|
+ ],$info['order_no'],1,1,'dc',[],$this->logic_tools->ret_arr(-1,'此单有已经完成的数据,不能进行同步'));
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $shipremarks = "";
|
|
|
+ $dc_list = [];
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ if(stripos($v['features'],'-131-') !== false)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $v['features'] = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v['features']);
|
|
|
+ $shipremarks = $v["text"];
|
|
|
+ $tmp_ret = $this->logic_u9tools->getOneU9bm($v['features'],$classid,$typeclass);
|
|
|
+ $dc_list[] =[
|
|
|
+ 'jm'=>$tmp_ret['jm'],
|
|
|
+ 'bm'=>$tmp_ret['bm'],
|
|
|
+ 'zh'=>$tmp_ret['zh'],
|
|
|
+ 'dcsl'=>$v['num'],
|
|
|
+ 'is_register'=>0,//商品是否被注册 先都当没注册 后面会先确认下
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if(empty($dc_list)){
|
|
|
+ $this->editData($info['id'],[
|
|
|
+ 'dc_status'=>-1,
|
|
|
+ 'update_time'=>time()
|
|
|
+ ],$info['order_no'],1,1,'dc',[],$this->logic_tools->ret_arr(-1,'此单sku转化为u9编码,发现没有匹配数据'));
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $time = time();
|
|
|
+ $dc_params = [
|
|
|
+ 'gys'=>$this->gys,//供应商
|
|
|
+ 'number'=>$info['order_no'],//erp订单编码
|
|
|
+ "TransOutDocType_Code"=>"TransOut001",//组织间调拨
|
|
|
+ "time"=>$time,
|
|
|
+ 'TransferDirection'=>0,//普通
|
|
|
+ 'yyid'=>"",//来源店铺 这种需要在店铺表中有
|
|
|
+ 'shipremarks'=>$shipremarks,//订单的备注
|
|
|
+ 'dcckbm'=>$this->xccp_code,//调出仓库编码
|
|
|
+ 'drckbm'=>$this->xgzt_code,//调入仓库编码
|
|
|
+ 'drzz_code'=>$this->xgzzcode,//调入组织Code
|
|
|
+ 'owner_code'=>$this->xczzcode,//货主组织Code
|
|
|
+ 'ztcode'=>$this->ztcode,//账套
|
|
|
+ 'tb_org_arr'=>$this->tb_org_arr,//要同步的组织列表
|
|
|
+ 'list'=>$dc_list
|
|
|
+ ];
|
|
|
+
|
|
|
+ $cxdcd_r = $this->apiyyv1->xcDcdByOtherId($dc_params['number'],$this->getToken(130));
|
|
|
+ $ret_data = $cxdcd_r[0]['Data'];
|
|
|
+ //调出单存在就不在执行了
|
|
|
+ if(isset($ret_data[0])){
|
|
|
+ $descflexfield_pubdescseg4 = $ret_data[0]['descflexfield_pubdescseg4'];
|
|
|
+ if($dc_params['number'] == $descflexfield_pubdescseg4){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //检测料品是否在u9被添加 检测香港组织有没有 许昌组织一定要有 没有
|
|
|
+ $r = $this->checkLp($dc_params,$this->getToken(140));
|
|
|
+
|
|
|
+ if($r['code'] !=1){
|
|
|
+ $this->editData($info['id'],['dc_status'=>-1,'update_time'=>time()],$info['order_no'],1,1,'lpck',$r['msg'][1],$r['msg'][0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ //创建调出单
|
|
|
+ $dcd_res = $this->apiyyv1->dcdCrate($dc_params,$this->getToken(130));
|
|
|
+
|
|
|
+ if(empty($dcd_res[0]['Data'][0]["Code"])){
|
|
|
+ $this->editData($info['id'],['dc_status'=>-1,'update_time'=>time()],$info['order_no'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ //更新
|
|
|
+ $dcd_no = $dcd_res[0]['Data'][0]["Code"];
|
|
|
+ $this->editData($info['id'],['dc_no'=>$dcd_no,'dc_status'=>1,'update_time'=>time()],$info['order_no'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
+
|
|
|
+ }
|
|
|
+ //查询调出单是否审核 审核了 就更新
|
|
|
+ public function cxDxcheck($info){
|
|
|
+ $r = $this->apiyyv1->xdlsCxDcd($info['dc_no'],$this->getToken(130));
|
|
|
+ if(empty($r[0]['Data'])){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新销售单数据
|
|
|
+ $xs_no = json_encode($r[0]['Data']);
|
|
|
+ $this->editData($info['id'],['dc_data'=>$xs_no,'dc_data_status'=>1,'dc_status'=>3,'update_time'=>time()],$info['order_no'],8,1,'dc_xc',$r[1],$r[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建销售单 和 采购单
|
|
|
+ public function createXsAndCg($info){
|
|
|
+ $tmp_data = $info['dc_data'];
|
|
|
+ if(empty($tmp_data)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $tmp_data = json_decode($info['dc_data'],true);
|
|
|
+ if(empty($tmp_data)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $list = [];
|
|
|
+ foreach($tmp_data as $key=>$val){
|
|
|
+ $list[] = [
|
|
|
+ 'jm'=>$val['iteminfo_itemcode'],
|
|
|
+ 'zh'=>$val['iteminfo_itemname'],
|
|
|
+ 'final_price'=>$val['costprice'],
|
|
|
+ 'dcsl'=>$val['costuomqty'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $time = time();
|
|
|
+ $do_params = [
|
|
|
+ 'gys'=>$this->gys,//供应商
|
|
|
+ 'number'=>$info['order_no'],//erp订单编码
|
|
|
+ "TransOutDocType_Code"=>"TransOut001",//组织间调拨
|
|
|
+ "time"=>$time,
|
|
|
+ 'TransferDirection'=>0,//普通
|
|
|
+ 'yyid'=>$this->yyid,//来源店铺 这种需要在店铺表中有
|
|
|
+ 'shipremarks'=>$tmp_data[0]['descflexfield_pubdescseg5'],//订单的备注
|
|
|
+ 'dcckbm'=>$this->xccp_code,//调出仓库编码
|
|
|
+ 'drckbm'=>$this->xgzt_code,//调入仓库编码
|
|
|
+ 'drzz_code'=>$this->xgzzcode,//调入组织Code
|
|
|
+ 'owner_code'=>$this->xczzcode,//货主组织Code
|
|
|
+ 'ztcode'=>$this->ztcode,//账套
|
|
|
+ 'tb_org_arr'=>$this->tb_org_arr,//要同步的组织列表
|
|
|
+ 'list'=>$list
|
|
|
+ ];
|
|
|
+ //创建许昌成品库的销售单
|
|
|
+ $xsd_res = $this->apiyyv1->xsdCreate($do_params,$this->getToken(130));
|
|
|
+ if(empty($xsd_res[0]['Data'][0]['m_code'])){
|
|
|
+ $this->editData($info['id'],['xs_status'=>-1,'update_time'=>time()],$info['order_no'],2,1,'xs',$xsd_res[1],$xsd_res[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ //更新销售单数据
|
|
|
+ $xs_no = $xsd_res[0]['Data'][0]["m_code"];
|
|
|
+ $this->editData($info['id'],['xs_no'=>$xs_no,'xs_status'=>1,'update_time'=>time()],$info['order_no'],2,1,'xs',$xsd_res[1],$xsd_res[0]);
|
|
|
+
|
|
|
+ //创建香港公司的采购单
|
|
|
+ $cgd_res = $this->apiyyv1->cgdCreate($do_params,$this->getToken(140));
|
|
|
+ if(empty($cgd_res[0]['Data'][0]["Code"])){
|
|
|
+ $this->editData($info['id'],['cg_status'=>-1,'update_time'=>time()],$info['order_no'],3,1,'cg',$cgd_res[1],$cgd_res[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->editData($info['id'],['cg_no'=>$cgd_res[0]['Data'][0]["Code"],'cg_status'=>1,'update_time'=>time()],$info['order_no'],3,1,'cg',$cgd_res[1],$cgd_res[0]);
|
|
|
+
|
|
|
+ }
|
|
|
+ //审核的调出单后 直接查询对应调入单 直接提交和审核
|
|
|
+ public function cxDrByDc($info){
|
|
|
+ $r = $this->apiyyv1->drdcxBydcd($info['dc_no'],$this->getToken(140));
|
|
|
+
|
|
|
+ //如果获取对应调入单没有成功
|
|
|
+ if(empty($r[0]['Data'][0]['docno'])){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $dr_no = $r[0]['Data'][0]["docno"];
|
|
|
+
|
|
|
+ $this->editData($info['id'],['dr_no'=>$dr_no,'dr_status'=>1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
|
|
|
+
|
|
|
+ //提交调入单
|
|
|
+ $rr = $this->apiyyv1->drdSubmit(['number'=>$dr_no],$this->getToken(140));
|
|
|
+ if(!$rr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['dr_status'=>2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
|
|
|
+
|
|
|
+ //审核调入单
|
|
|
+ $rrr = $this->apiyyv1->drdApprove(['number'=>$dr_no],$this->getToken(140));
|
|
|
+ if(!$rrr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['dr_status'=>3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
|
|
|
+ }
|
|
|
+ //提交和审核销售单
|
|
|
+ public function shCgAndXs($info){
|
|
|
+ $r = $this->apiyyv1->cgdSubmit([
|
|
|
+ 'number'=>$info['cg_no']
|
|
|
+ ],$this->getToken(140));
|
|
|
+
|
|
|
+ if(!$r[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['cg_status'=>-2,'update_time'=>time()],$info['order_no'],3,2,'cg',$r[1],$r[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //更新采购单
|
|
|
+ $this->editData($info['id'],['cg_status'=>2,'update_time'=>time()],$info['order_no'],3,2,'cg',$r[1],$r[0]);
|
|
|
+ $rr = $this->apiyyv1->cgdApprove([
|
|
|
+ 'number'=>$info['cg_no']
|
|
|
+ ],$this->getToken(140));
|
|
|
+ if(!$rr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['cg_status'=>-3,'update_time'=>time()],$info['order_no'],3,3,'cg',$rr[1],$rr[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['cg_status'=>3,'update_time'=>time()],$info['order_no'],3,3,'cg',$rr[1],$rr[0]);
|
|
|
+
|
|
|
+ $r = $this->apiyyv1->xsdSubmit([
|
|
|
+ 'number'=>$info['xs_no']
|
|
|
+ ],$this->getToken(130));
|
|
|
+
|
|
|
+ if(!$r[0]['Data'][0]['m_isSucess']){
|
|
|
+ $this->editData($info['id'],['xs_status'=>-2,'update_time'=>time()],$info['order_no'],2,2,'xs',$r[1],$r[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['xs_status'=>2,'update_time'=>time()],$info['order_no'],2,2,'xs',$r[1],$r[0]);
|
|
|
+ $rr = $this->apiyyv1->xsdApprove([
|
|
|
+ 'number'=>$info['xs_no']
|
|
|
+ ],$this->getToken(130));
|
|
|
+ if(!$rr[0]['Data'][0]['m_isSucess']){
|
|
|
+ $this->editData($info['id'],['xs_status'=>-3,'update_time'=>time()],$info['order_no'],2,3,'xs',$rr[1],$rr[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['xs_status'=>3,'update_time'=>time()],$info['order_no'],2,3,'xs',$rr[1],$rr[0]);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建在途库存调入美仓的调出单
|
|
|
+ public function createDcTwo($info){
|
|
|
+ $time = time();
|
|
|
+ $tmp_list = $this->zzquque_u9->find_all("order_no = '".$info['order_no']."' and type = 1 and dc_status = 3 and xs_status = 3 and cg_status = 3 and dr_status = 3");
|
|
|
+
|
|
|
+ if(empty($tmp_list)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $tmp_info = $tmp_list[0];
|
|
|
+ if(empty($tmp_info['dc_data'])){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $tmp_data = json_decode($tmp_info['dc_data'],true);
|
|
|
+ if(empty($tmp_data)){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $dc_list = [];
|
|
|
+ foreach($tmp_data as $key=>$val){
|
|
|
+ $dc_list[] = [
|
|
|
+ 'jm'=>$val['iteminfo_itemcode'],
|
|
|
+ 'dcsl'=>$val['costuomqty'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $dc_params = [
|
|
|
+ 'gys'=>$this->gys,//供应商
|
|
|
+ 'number'=>$info['order_no'],//erp订单编码
|
|
|
+ "TransOutDocType_Code"=>"TransOut002",//仓库转储
|
|
|
+ "time"=>$time,
|
|
|
+ 'TransferDirection'=>0,//普通
|
|
|
+ 'yyid'=>"",//来源店铺 这种需要在店铺表中有
|
|
|
+ 'shipremarks'=>$tmp_data[0]['descflexfield_pubdescseg5'],//订单的备注
|
|
|
+ 'dcckbm'=>$this->xgzt_code,//调出仓库编码 在途库
|
|
|
+ 'drckbm'=>$this->xgmc_code,//调入仓库编码 美仓
|
|
|
+ 'drzz_code'=>$this->xgzzcode,//调入组织Code
|
|
|
+ 'owner_code'=>$this->xgzzcode,//货主组织Code
|
|
|
+ 'ztcode'=>$this->ztcode,//账套
|
|
|
+ 'tb_org_arr'=>$this->tb_org_arr,//要同步的组织列表
|
|
|
+ 'list'=>$dc_list
|
|
|
+ ];
|
|
|
+ //创建调出单
|
|
|
+ $dcd_res = $this->apiyyv1->dcdCrate($dc_params,$this->getToken(140));
|
|
|
+
|
|
|
+ if(empty($dcd_res[0]['Data'][0]["Code"])){
|
|
|
+ $this->editData($info['id'],['dc_status'=>-1,'update_time'=>time()],$info['order_no'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ //更新
|
|
|
+ $dcd_no = $dcd_res[0]['Data'][0]["Code"];
|
|
|
+ $this->editData($info['id'],['dc_no'=>$dcd_no,'dc_status'=>1,'update_time'=>time()],$info['order_no'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
+ sleep(2);
|
|
|
+ $info['dc_no'] = $dcd_no;
|
|
|
+ $info['dc_status'] = 1;
|
|
|
+ $r = $this->shDcTwo($info);
|
|
|
+ if(!$r){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ sleep(2);
|
|
|
+ $info['dc_status'] = 3;
|
|
|
+ $r = $this->cxDcTwo($info);
|
|
|
+
|
|
|
+ }
|
|
|
+ //提交审核
|
|
|
+ public function shDcTwo($info){
|
|
|
+ $r = $this->apiyyv1->dcdSubmit([
|
|
|
+ 'number'=>$info['dc_no']
|
|
|
+ ],$this->getToken(140));
|
|
|
+ if(!$r[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dc_status'=>-2,'update_time'=>time()],$info['order_no'],1,2,'dc',$r[1],$r[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //更新调出单
|
|
|
+ $this->editData($info['id'],['dc_status'=>2,'update_time'=>time()],$info['order_no'],1,2,'dc',$r[1],$r[0]);
|
|
|
+ $rr = $this->apiyyv1->dcdApprove([
|
|
|
+ 'number'=>$info['dc_no']
|
|
|
+ ],$this->getToken(140));
|
|
|
+ if(!$rr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dc_status'=>-3,'update_time'=>time()],$info['order_no'],1,3,'dc',$rr[1],$rr[0]);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['dc_status'=>3,'update_time'=>time()],$info['order_no'],1,3,'dc',$rr[1],$rr[0]);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //查询调出单审核调出单 同时更新的
|
|
|
+ public function cxDcTwo($info){
|
|
|
+ $r = $this->apiyyv1->drdcxBydcd($info['dc_no'],$this->getToken(140));
|
|
|
+
|
|
|
+ //如果获取对应调入单没有成功
|
|
|
+ if(empty($r[0]['Data'][0]['docno'])){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $dr_no = $r[0]['Data'][0]["docno"];
|
|
|
+
|
|
|
+ $this->editData($info['id'],['dr_no'=>$dr_no,'dr_status'=>1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
|
|
|
+
|
|
|
+ //提交调入单
|
|
|
+ $rr = $this->apiyyv1->drdSubmit(['number'=>$dr_no],$this->getToken(140));
|
|
|
+ if(!$rr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['dr_status'=>2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
|
|
|
+
|
|
|
+ //审核调入单
|
|
|
+ $rrr = $this->apiyyv1->drdApprove(['number'=>$dr_no],$this->getToken(140));
|
|
|
+ if(!$rrr[0]['Data'][0]['IsSucess']){
|
|
|
+ $this->editData($info['id'],['dr_status'=>-3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $this->editData($info['id'],['dr_status'=>3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据返回的状态修改对应的值
|
|
|
+ protected function editData($zq_u9_id,$z_qu_arr,$number,$one_type,$two_type,$apply_api,$apply_data,$ret_data){
|
|
|
+ $this->zzquque_u9->save($z_qu_arr,$zq_u9_id);
|
|
|
+ $this->zzququeu9_logs->insert([
|
|
|
+ 'oid'=>$zq_u9_id,
|
|
|
+ 'number'=>$number,
|
|
|
+ 'one_type'=>$one_type,
|
|
|
+ 'two_type'=>$two_type,
|
|
|
+ 'apply_api'=>$apply_api,
|
|
|
+ 'apply_data'=>json_encode($apply_data,JSON_UNESCAPED_UNICODE),
|
|
|
+ 'ret_data'=>json_encode($ret_data,JSON_UNESCAPED_UNICODE),
|
|
|
+ 'create_time'=>time(),
|
|
|
+ 'read_time'=>date("Y-m-d H:i:s")
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查u9编码是否存在 如果不存在 请先添加并
|
|
|
+ protected function checkLp($info,$token){
|
|
|
+ //未注册的货品的列表
|
|
|
+ $unregister_goods = [];
|
|
|
+ $r = $this->apiyyv1->cxLp($info['list'],$token);
|
|
|
+ if(!$r[0]['Success']){
|
|
|
+ return $this->logic_tools->ret_arr(-1,'查询商品信息异常'.json_encode($r,JSON_UNESCAPED_UNICODE));
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($r[0]['Data'] as $k=>$v)
|
|
|
+ {
|
|
|
+ foreach($info['list'] as $kk => $vv){
|
|
|
+ if($v['m_code'] == $vv['jm']){
|
|
|
+ $info['list'][$kk]['is_register'] = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach($info['list'] as $k => $v){
|
|
|
+ if($v['is_register'] == 0){
|
|
|
+ $unregister_goods[] = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($unregister_goods)){
|
|
|
+ return $this->logic_tools->ret_arr(1,"料品无异常");
|
|
|
+ }
|
|
|
+ $tb_info = $info;
|
|
|
+ $tb_info['list'] = $unregister_goods;
|
|
|
+ // //return $this->tbXgLp($tb_info,$token);
|
|
|
+ return $this->tbXgLp($tb_info);
|
|
|
+ }
|
|
|
+ //将许昌仓的料品同步到香港仓
|
|
|
+ public function tbXgLp($tb_info){
|
|
|
+
|
|
|
+ $rr = $this->apiyyv1->tbLp($tb_info,$this->getToken(130));
|
|
|
+
|
|
|
+ if($rr[0]['Success']){
|
|
|
+ return $this->logic_tools->ret_arr(1,$rr);
|
|
|
+ }else{
|
|
|
+ return $this->logic_tools->ret_arr(-1,$rr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|