|
@@ -0,0 +1,448 @@
|
|
|
|
+<?php
|
|
|
|
+/**
|
|
|
|
+ * 手动处理香港小单列表的功能
|
|
|
|
+ */
|
|
|
|
+class Model_logic_u9xgsd extends Lin_Model {
|
|
|
|
+ public $xdzzcode = '130';//许昌销售公司编码
|
|
|
|
+ public $xdcp_code = '13001';//许昌成品库的编码 测试的时候就用龙盈工厂的仓库
|
|
|
|
+ public $xdxgzzcode = '140';//香港组织公司编码
|
|
|
|
+ public $xdxgls_code = '14003';//香港临时库的编码 测试的时候用销售公司成品库的编码
|
|
|
|
+ public $ztcode = '9966';//账套的code;
|
|
|
|
+ public $tb_org_arr =[101,110,130,140];//同步组织
|
|
|
|
+ public $gys = "98002";//供应商 98001 龙盈 98002 龙熠
|
|
|
|
+ //切记要修改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");
|
|
|
|
+ }
|
|
|
|
+ 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 createData($info){
|
|
|
|
+ $pre_data = $this->transPrepare();
|
|
|
|
+ $typeclass = $pre_data['typeclass'];
|
|
|
|
+ $classid = $pre_data['classid'];
|
|
|
|
+ $time = time();
|
|
|
|
+ $list = [];
|
|
|
|
+ $fpdata = $info['fpdata'];
|
|
|
|
+ $fpdata_list = explode(';',trim( $fpdata,';'));
|
|
|
|
+ $whlabel_list = explode("|",trim($info['whlabel'],"|"));
|
|
|
|
+
|
|
|
|
+ $total_goods_num = 0;//订单产品总数量
|
|
|
|
+ foreach($whlabel_list as $k=>$v){
|
|
|
|
+ $tmp_data = explode("-",trim($v,'-'));
|
|
|
|
+ if(isset($tmp_data[1])){
|
|
|
|
+ $total_goods_num += $tmp_data[1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $avg_price = floor(($info['skje']*1000)/$total_goods_num)/1000;
|
|
|
|
+ foreach($fpdata_list as $k=>$v){
|
|
|
|
+ $tmp_str = str_replace(array('-163-','-164-','-165-','-166-'),'-',$v);
|
|
|
|
+ $tmp_arr = explode('|',trim($tmp_str,'|'));
|
|
|
|
+ if(stripos($tmp_arr[0],',') !== false){
|
|
|
|
+ $ft = explode(',',$tmp_arr[0]);
|
|
|
|
+ $features = explode('-',trim($ft[1],'-'));
|
|
|
|
+ $features[] = $ft[0];
|
|
|
|
+ }else{
|
|
|
|
+ $features = explode('-',trim($tmp_arr[0],'-'));
|
|
|
|
+ }
|
|
|
|
+ $sku = implode("-",$features);
|
|
|
|
+ $tmp_ret = $this->logic_u9tools->getOneU9bm($sku,$classid,$typeclass);
|
|
|
|
+ $list[] = [
|
|
|
|
+ 'jm'=>$tmp_ret['jm'],
|
|
|
|
+ 'bm'=>$tmp_ret['bm'],
|
|
|
|
+ 'zh'=>$tmp_ret['zh'],
|
|
|
|
+ 'final_price'=>$avg_price,//目前先不设置 等后期财务说了再说
|
|
|
|
+ 'title'=>isset($tmp_arr[1])?$tmp_arr[1]:'无',
|
|
|
|
+ 'dcsl'=>$tmp_arr[2],
|
|
|
|
+ 'is_register'=>0,//商品是否被注册 先都当没注册 后面会先确认下
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ $shop = $this->shop->read($info['shop']);
|
|
|
|
+ if(empty($shop['yyid'])){
|
|
|
|
+ //如果没有在u9上设置店铺的组织 那么需要设置
|
|
|
|
+ $this->editData($info['zq_u9_id'],['dc_status'=>-1,'update_time'=>time()],$info['number'],1,1,'',[],$this->logic_tools->ret_arr(-1,'店铺没有在u9平台设置参数'));
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $dc_params = [
|
|
|
|
+ 'gys'=>$this->gys,//供应商
|
|
|
|
+ 'number'=>$info['number'],//erp订单编码
|
|
|
|
+ "TransOutDocType_Code"=>"TransOut001",//组织间调拨
|
|
|
|
+ "time"=>$time,
|
|
|
|
+ 'TransferDirection'=>0,//普通
|
|
|
|
+ 'yyid'=>$shop['yyid'],//来源店铺 这种需要在店铺表中有
|
|
|
|
+ 'shipremarks'=>$info['shipremarks'],//订单的备注
|
|
|
|
+ 'dcckbm'=>$this->xdcp_code,//调出仓库编码
|
|
|
|
+ 'drckbm'=>$this->xdxgls_code,//调入仓库编码
|
|
|
|
+ 'drzz_code'=>$this->xdxgzzcode,//调入组织Code
|
|
|
|
+ 'owner_code'=>$this->xdzzcode,//货主组织Code
|
|
|
|
+ 'ztcode'=>$this->ztcode,//账套
|
|
|
|
+ 'tb_org_arr'=>$this->tb_org_arr,//要同步的组织列表
|
|
|
|
+ 'list'=>$list
|
|
|
|
+ ];
|
|
|
|
+ return $dc_params;
|
|
|
|
+ }
|
|
|
|
+ //创建调出单
|
|
|
|
+ public function createDc($tmp_info){
|
|
|
|
+ $info = $this->logic_order->getInfoByPlat($tmp_info['platform'],$tmp_info['order_no']);
|
|
|
|
+ $info['zq_u9_id'] = $tmp_info['id'];
|
|
|
|
+ $dc_params = $this->createData($info);
|
|
|
|
+ //调出单检测是否存在
|
|
|
|
+ $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 $this->logic_tools->ret_arr(-1,"对应的销售单已存在请勿重复操作");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //检测料品是否在u9被添加 检测香港仓有没有 许昌仓一定要有 没有
|
|
|
|
+ $r = $this->checkLp($dc_params,$this->getToken(140));
|
|
|
|
+
|
|
|
|
+ if($r['code'] !=1){
|
|
|
|
+ $this->editData($info['zq_u9_id'],['dc_status'=>-1,'update_time'=>time()],$info['number'],1,1,'lpck',[],$r['msg']);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"同步料品失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //创建调出单
|
|
|
|
+ $dcd_res = $this->apiyyv1->dcdCrate($dc_params,$this->getToken(130));
|
|
|
|
+
|
|
|
|
+ if(empty($dcd_res[0]['Data'][0]["Code"])){
|
|
|
|
+ $this->editData($info['zq_u9_id'],['dc_status'=>-1,'update_time'=>time()],$info['number'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"创建调出单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新
|
|
|
|
+ $dcd_no = $dcd_res[0]['Data'][0]["Code"];
|
|
|
|
+ $this->editData($info['zq_u9_id'],['dc_no'=>$dcd_no,'dc_status'=>1,'update_time'=>time()],$info['number'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"创建调出单成功");
|
|
|
|
+ }
|
|
|
|
+ //提交调出单
|
|
|
|
+ public function subDc($info){
|
|
|
|
+ $r = $this->apiyyv1->dcdSubmit([
|
|
|
|
+ 'number'=>$info['dc_no']
|
|
|
|
+ ],$this->getToken(130));
|
|
|
|
+ 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 $this->logic_tools->ret_arr(-1,"提交调出单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新调出单
|
|
|
|
+ $this->editData($info['id'],['dc_status'=>2,'update_time'=>time()],$info['order_no'],1,2,'dc',$r[1],$r[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交调出单失败");
|
|
|
|
+ }
|
|
|
|
+ //审核调出单
|
|
|
|
+ public function shDc($info){
|
|
|
|
+ $rr = $this->apiyyv1->dcdApprove([
|
|
|
|
+ 'number'=>$info['dc_no']
|
|
|
|
+ ],$this->getToken(130));
|
|
|
|
+ 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 $this->logic_tools->ret_arr(-1,"审核调出单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['dc_status'=>3,'update_time'=>time()],$info['order_no'],1,3,'dc',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核调出单成功");
|
|
|
|
+ }
|
|
|
|
+ //创建采购单
|
|
|
|
+ public function createCg($tmp_info){
|
|
|
|
+ $info = $this->logic_order->getInfoByPlat($tmp_info['platform'],$tmp_info['order_no']);
|
|
|
|
+ $info['zq_u9_id'] = $tmp_info['id'];
|
|
|
|
+ $dc_params = $this->createData($info);
|
|
|
|
+ //创建香港公司的采购单
|
|
|
|
+ $cgd_res = $this->apiyyv1->cgdCreate($dc_params,$this->getToken(140));
|
|
|
|
+ if(empty($cgd_res[0]['Data'][0]["Code"])){
|
|
|
|
+ $this->editData($info['zq_u9_id'],['cg_status'=>-1,'update_time'=>time()],$info['number'],3,1,'cg',$cgd_res[1],$cgd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"创建采购单失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $this->editData($info['zq_u9_id'],['cg_no'=>$cgd_res[0]['Data'][0]["Code"],'cg_status'=>1,'update_time'=>time()],$info['number'],3,1,'cg',$cgd_res[1],$cgd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"创建采购单成功");
|
|
|
|
+ }
|
|
|
|
+ //提交采购单
|
|
|
|
+ public function subCg($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 $this->logic_tools->ret_arr(-1,"提交采购单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新采购单
|
|
|
|
+ $this->editData($info['id'],['cg_status'=>2,'update_time'=>time()],$info['order_no'],3,2,'cg',$r[1],$r[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交采购单成功");
|
|
|
|
+ }
|
|
|
|
+ //审核采购单
|
|
|
|
+ public function shCg($info){
|
|
|
|
+ $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 $this->logic_tools->ret_arr(-1,"审核采购单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['cg_status'=>3,'update_time'=>time()],$info['order_no'],3,3,'cg',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核采购单成功");
|
|
|
|
+ }
|
|
|
|
+ //创建销售单
|
|
|
|
+ public function createXs($tmp_info){
|
|
|
|
+
|
|
|
|
+ $info = $this->logic_order->getInfoByPlat($tmp_info['platform'],$tmp_info['order_no']);
|
|
|
|
+ $info['zq_u9_id'] = $tmp_info['id'];
|
|
|
|
+ $dc_params = $this->createData($info);
|
|
|
|
+ //创建许昌成品库的销售单
|
|
|
|
+ $xsd_res = $this->apiyyv1->xsdCreate($dc_params,$this->getToken(130));
|
|
|
|
+ if(empty($xsd_res[0]['Data'][0]['m_code'])){
|
|
|
|
+ $this->editData($info['zq_u9_id'],['xs_status'=>-1,'update_time'=>time()],$info['number'],2,1,'xs',$xsd_res[1],$xsd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"创建销售单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新销售单数据
|
|
|
|
+ $xs_no = $xsd_res[0]['Data'][0]["m_code"];
|
|
|
|
+ $this->editData($info['zq_u9_id'],['xs_no'=>$xs_no,'xs_status'=>1,'update_time'=>time()],$info['number'],2,1,'xs',$xsd_res[1],$xsd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"创建销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //提交销售单
|
|
|
|
+ public function subXs($info){
|
|
|
|
+ $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 $this->logic_tools->ret_arr(-1,"提交销售单成功");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['xs_status'=>2,'update_time'=>time()],$info['order_no'],2,2,'xs',$r[1],$r[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //审核销售单
|
|
|
|
+ public function shXs($info){
|
|
|
|
+ $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 $this->logic_tools->ret_arr(-1,"审核销售单成功");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['xs_status'=>3,'update_time'=>time()],$info['order_no'],2,3,'xs',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //创建关联销售单
|
|
|
|
+ public function createXsTwo($tmp_info){
|
|
|
|
+ $info = $this->logic_order->getInfoByPlat($tmp_info['platform'],$tmp_info['order_no']);
|
|
|
|
+ $info['zq_u9_id'] = $tmp_info['id'];
|
|
|
|
+ $dc_params = $this->createData($info);
|
|
|
|
+ //创建香港仓的销售单
|
|
|
|
+ $xsd_res = $this->apiyyv1->xsdCreate($dc_params,$this->getToken(140));
|
|
|
|
+
|
|
|
|
+ if(empty($xsd_res[0]['Data'][0]['m_code'])){
|
|
|
|
+ $this->editData($info['zq_u9_id'],['xs_two_status'=>-1,'update_time'=>time()],$info['number'],7,1,'xs_two',$xsd_res[1],$xsd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"创建香港销售单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新销售单数据
|
|
|
|
+ $xs_no = $xsd_res[0]['Data'][0]["m_code"];
|
|
|
|
+ $this->editData($info['zq_u9_id'],['xs_two_no'=>$xs_no,'xs_two_status'=>1,'update_time'=>time()],$info['number'],7,1,'xs_two',$xsd_res[1],$xsd_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"创建香港销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //提交审关联销售单
|
|
|
|
+ public function subXsTwo($info){
|
|
|
|
+ $r = $this->apiyyv1->xsdSubmit([
|
|
|
|
+ 'number'=>$info['xs_two_no']
|
|
|
|
+ ],$this->getToken(140));
|
|
|
|
+
|
|
|
|
+ if(!$r[0]['Data'][0]['m_isSucess']){
|
|
|
|
+ $this->editData($info['id'],['xs_two_status'=>-2,'update_time'=>time()],$info['order_no'],2,2,'xs',$r[1],$r[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"提交香港销售单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['xs_two_status'=>2,'update_time'=>time()],$info['order_no'],2,2,'xs',$r[1],$r[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交香港销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //审核关联销售单
|
|
|
|
+ public function shXsTwo($info){
|
|
|
|
+ $rr = $this->apiyyv1->xsdApprove([
|
|
|
|
+ 'number'=>$info['xs_two_no']
|
|
|
|
+ ],$this->getToken(140));
|
|
|
|
+ if(!$rr[0]['Data'][0]['m_isSucess']){
|
|
|
|
+ $this->editData($info['id'],['xs_two_status'=>-3,'update_time'=>time()],$info['order_no'],2,3,'xs',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"审核香港销售单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['xs_two_status'=>3,'update_time'=>time()],$info['order_no'],2,3,'xs',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核香港销售单成功");
|
|
|
|
+ }
|
|
|
|
+ //创建出货单
|
|
|
|
+ public function createCh($info){
|
|
|
|
+ $r = $this->apiyyv1->xscsByordernos([$info['xs_two_no']],$this->getToken(140));
|
|
|
|
+
|
|
|
|
+ if(empty($r[0]['Data'])){
|
|
|
|
+ return ;
|
|
|
|
+ }
|
|
|
|
+ $tmp_list = [];
|
|
|
|
+ foreach($r[0]['Data'] as $k=>$v){
|
|
|
|
+ $v['dcsl'] = $v['shipplanqtypu'];
|
|
|
|
+ $tmp_list[$v['docno']][] = $v;
|
|
|
|
+ }
|
|
|
|
+ $list = [$info];
|
|
|
|
+ $final_list = [];
|
|
|
|
+ foreach($tmp_list as $k=>$v){
|
|
|
|
+ foreach($list as $item){
|
|
|
|
+ if($item['xs_two_no'] == $k){
|
|
|
|
+ $final_list[] = [
|
|
|
|
+ 'zq_u9_id'=>$item['id'],
|
|
|
|
+ 'drckbm'=>$this->xdxgls_code,
|
|
|
|
+ 'number'=>$item['order_no'],
|
|
|
|
+ 'order_no'=>$item['order_no'],
|
|
|
|
+ 'xs_no'=>$k,
|
|
|
|
+ 'xs_two_no'=>$k,
|
|
|
|
+ 'list'=>$v
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $do_data = $final_list[0];
|
|
|
|
+ $bzch_res = $this->apiyyv1->bzchCreate($do_data,$this->getToken(140));
|
|
|
|
+ if(empty($bzch_res[0]['Data'][0]['m_code'])){
|
|
|
|
+ $this->editData($info['id'],['bzch_status'=>-1,'update_time'=>time()],$info['order_no'],4,1,'bzch',$bzch_res[1],$bzch_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"创建标准出货单失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新销售单数据
|
|
|
|
+ $bzch_no = $bzch_res[0]['Data'][0]["m_code"];
|
|
|
|
+ $this->editData($info['id'],['bzch_no'=>$bzch_no,'bzch_status'=>1,'update_time'=>time()],$info['order_no'],4,1,'bzch',$bzch_res[1],$bzch_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"创建标准出货单成功");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ //提交并审核出货单
|
|
|
|
+ public function subAndShCh($info){
|
|
|
|
+ $bzch_res = $this->apiyyv1->bzchSubmitAndApprove(['number'=>$info['bzch_no']],$this->getToken(140));
|
|
|
|
+ if(empty($bzch_res[0]['Data'][0]['m_code'])){
|
|
|
|
+ $this->editData($info['id'],['bzch_status'=>-3,'update_time'=>time()],$info['order_no'],4,3,'bzch',$bzch_res[1],$bzch_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(-1,"提交标准出货单失败");
|
|
|
|
+ }
|
|
|
|
+ //更新销售单数据
|
|
|
|
+ $bzch_no = $bzch_res[0]['Data'][0]["m_code"];
|
|
|
|
+ $this->editData($info['id'],['bzch_no'=>$bzch_no,'bzch_status'=>3,'update_time'=>time()],$info['order_no'],4,3,'bzch',$bzch_res[1],$bzch_res[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交标准出货单成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询调入单
|
|
|
|
+ public function createDr($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 $this->logic_tools->ret_arr(-1,"审核标准出货单失败");
|
|
|
|
+ }
|
|
|
|
+ $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]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核标准出货单成功");
|
|
|
|
+ }
|
|
|
|
+ //提交调入单
|
|
|
|
+ public function subDr($info){
|
|
|
|
+ //提交调入单
|
|
|
|
+ $rr = $this->apiyyv1->drdSubmit(['number'=>$info['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->logic_tools->ret_arr(-1,"提交调入单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['dr_status'=>2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"提交调入单成功");
|
|
|
|
+ }
|
|
|
|
+ //审核调入单
|
|
|
|
+ public function shDr($info){
|
|
|
|
+ //审核调入单
|
|
|
|
+ $rrr = $this->apiyyv1->drdApprove(['number'=>$info['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->logic_tools->ret_arr(-1,"审核调入单失败");
|
|
|
|
+ }
|
|
|
|
+ $this->editData($info['id'],['dr_status'=>3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
|
|
|
|
+ return $this->logic_tools->ret_arr(1,"审核调入单成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //检查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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //根据返回的状态修改对应的值
|
|
|
|
+ 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")
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|