更新对账接口

parent df8211dd
......@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Model\Server\ServerFinanceModel;
use App\Model\Server\ServerPurModel;
use App\Model\SupplierAccountModel;
use Illuminate\Http\Request;
use App\Http\Requests;
......@@ -26,5 +28,43 @@ class ApiController extends Controller
private function ApiForgetPassword($request, $id){
Export((new SupplierAccountModel())->ForgetPassword($request));
}
//库存变化明细
private function ApiStockChangeItems($request, $id){
(new ServerPurModel($request->appid,$request->key))->StockChangeItemsList($request->input());
}
//订单列表
private function ApiOrderList($request, $id){
(new ServerPurModel($request->appid,$request->key))->OrderList($request->input());
}
//订单列表导出
private function ApiOrderListExport($request, $id){
$res = (new ServerPurModel($request->appid,$request->key))->OrderList($request->input());
if (!count($res['data']) ){
exit("没有数据");
}
if (count($res['data']) >5000){
exit("导出条数不得大于5000");
}
unset($res['data']['id']);
unset($res['data']['putaway_time']);
export_csv($res['data'],['订单号','订单金额','币种','结算方式','状态','创建时间'],'订单列表导出');
}
//订单列表
private function ApiOrderDetail($request, $id){
(new ServerPurModel($request->appid,$request->key))->OrderDetail($request->input());
}
//获取对账单列表
private function ApiAccountCheckingList($request, $id){
(new ServerFinanceModel($request->appid,$request->key))->accountCheckingList($request->input());
}
//获取对账单列表明细
private function ApiAccountCheckingDetail($request, $id){
(new ServerFinanceModel($request->appid,$request->key))->accountCheckingDetail($request->input());
}
//退货列表明细
private function ApiAbnormalDetail($request, $id){
(new ServerFinanceModel($request->appid,$request->key))->accountChangeChecking($request->input());
}
}
......@@ -16,7 +16,6 @@ use App\Model\PurchaseDeliveryModel;
use App\Model\PurchaseItemsModel;
use App\Model\PurchaseModel;
use App\Model\PutawayItemsModel;
use App\Model\Report\ReportSkuModel;
use App\Model\Server\FoostoneModel;
use App\Model\SnModel;
use Illuminate\Http\Request;
......@@ -46,9 +45,15 @@ class HandleController extends Controller
$info=[
'goods_id'=>11076,'cost'=>'ADI'
];
$data=ExcessEncryption($info,'liexin20190128castervbht=1@k','DEvLbH82HMj$ZSjxNZW#M%5Xgn9dvsvT');
//$data=ExcessEncryption($info,'liexin20190128castervbht=1@k','DEvLbH82HMj$ZSjxNZW#M%5Xgn9dvsvT');
$data=ExcessEncryption($info,'98edc594bfac7353f7644c07c328fc88','c99f5662b56977c3168e6659f5d64daf');
print_r($data);
print_r(ExcessDecrypt($data));
die();
$url='http://footstone.liexin.com/third/api/obtain/list/sku';
$res = (curl($url,$data));
print_r($res);
die();
print_r(\GuzzleHttp\json_decode($res,true));
}
/*
......
......@@ -24,18 +24,21 @@ class CheckLogin
if (empty($yunxin_token) || empty($userInfo) ){ //没有登录跳到登录页
if (strpos($nowUrl,'/api/ApiLogin') == false && strpos($nowUrl,'/api/ApiForgetPassword') == false && $isApi){
return [-1,'请登录'];
Export([-1,'请登录']);
}
if (strpos($nowUrl,'/web/login') == false && strpos($nowUrl,'/web/ForgetPassword') == false &&!$isApi){
return redirect('/web/login' );
}
}
Redis::expire('yunxin_login_'.$yunxin_token,7200);
$userInfoArr = json_decode($userInfo,true);
$request->account_id = $userInfoArr['account_id'];
$request->supplier_id = $userInfoArr['supplier_id'];
$request->supplier_name = $userInfoArr['supplier_name'];
$request->role_id = $userInfoArr['role_id'];
$request->role_id = $userInfoArr['role_id']; //1寄售 2自采 3云芯
$request->yunxin_token = $yunxin_token;
$request->appid = $userInfoArr['appid'];
$request->key = $userInfoArr['key'];
return $next($request);
}
......
......@@ -1021,17 +1021,17 @@ function SelectDb($db,$sql){
}
function Export($errcode=0,$errmsg='成功',$data=''){
if(is_array($errcode)){
echo json_encode(['code'=>$errcode[0],'msg'=>$errcode[1],'data'=>!empty(@$errcode[2])?@$errcode[2]:''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
echo json_encode(['errcode'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>!empty(@$errcode[2])?@$errcode[2]:''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}else{
echo json_encode(['code'=>$errcode,'msg'=>$errmsg,'data'=>$data], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
echo json_encode(['errcode'=>$errcode,'errmsg'=>$errmsg,'data'=>$data], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}
exit();
}
function ExportLayui($errcode=0,$errmsg=0,$data=[],$count=0,$other=''){
if(is_array($errcode)){
echo json_encode(['code'=>$errcode[0],'msg'=>$errcode[1],'data'=>@$errcode[2],'count'=>@$errcode[3],'other'=>!empty(@$errcode[4]) ? @$errcode[4] : ''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
echo json_encode(['errcode'=>$errcode[0],'errmsg'=>$errcode[1],'data'=>@$errcode[2],'count'=>@$errcode[3],'other'=>!empty(@$errcode[4]) ? @$errcode[4] : ''], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}else{
echo json_encode(['code'=>$errcode,'msg'=>$errmsg,'data'=>$data,'count'=>$count,'other'=>$other], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
echo json_encode(['errcode'=>$errcode,'errmsg'=>$errmsg,'data'=>$data,'count'=>$count,'other'=>$other], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
}
exit();
}
......@@ -1073,10 +1073,14 @@ function ExcessEncryption($info,$appid,$key){
/**
* 解密第三方仓库加密
*/
function ExcessDecrypt($data,$key){
function ExcessDecrypt($data,$key = ""){
if(time()-(int)$data['timestamp']>10) return [10000,'时间戳验证超时,请更新当前客户端时间'];
$Redis=new \App\Model\RedisModel();
$Redis=RedisDB::connection();
if ($key == ""){
$info = $Redis->hget("Self_third_supplier_appid",$data['appid']); //查询供应商key,拿到key
if(!$info) return [1001,'不存在密钥'];
$key = json_decode($info,'true')['key'];
}
if($data['token']!==md5($data['data'].$data['timestamp'].$key.$data['appid'])) return [10001,'Token验证失败'];
$info=json_decode(Deciphering($data['data'],$key),true);
if(empty($info)) return [10004,'解密失败'];
......@@ -1133,4 +1137,20 @@ function SendMsg($data, $key = '', $ToUser = 'INNER_PERSON'){
$res = json_decode($return,true);
if(empty($res['err_code']) || $res['err_code']!=0) return false;
return true;
}
/*
* 返回拼接的搜索字符串
* @param string $fen 分割的字符
* @param array $key 查询字段
* @param array $data 需要整理的数据
* @param int $type 1 模糊查询 2 准确查询
*/
function GetLikeStr($fen,$key,$data,$type = 1){
$d = explode($fen,$data);
$s = "" ;
foreach ($d as $k=>$v){
$s .= $type == 1 ? "($key like '%".trim($v)."%') or " : sprintf("'%s'",trim($v)).",";
}
$s = $type == 1 ? rtrim($s,'or ') : $key.' in ('.trim($s,',').")";
return $s;
}
\ No newline at end of file
......@@ -7,4 +7,5 @@ Route::group(['middleware' => 'web'], function () {
});
Route::match(['get', 'post'],'/helper/{key}', 'HelperController@Entrance');
Route::match(['get', 'post'],'/hd/{key}', 'HandleController@Entrance');
\ No newline at end of file
Route::match(['get', 'post'],'/hd/{key}', 'HandleController@Entrance');
<?php
namespace App\Model\Server;
use App\map\PreSaleOrderMap;
use App\Model\OperationLogModel;
use ClassPreloader\Config;
use League\Flysystem\Exception;
use Request;
use DB;
/*
* 采购与基石交流公共接口
*/
class FoostoneModel
{
const IS_DEBUG = false;
/*
* 请求
* @param $map post的数据
* @param string $url post的网址
* @return $array
*/
static function push($data,$url){
$url = Config("website.serviceUrl").$url.'?token='. md5($data['data'].$data['timestamp'].Config("fixed.WMSKEY"));
// $url = "http://szfootstone.ichunt.net/".$url.'?token='. md5($data['data'].$data['timestamp'].Config("fixed.WMSKEY"));
$res = post_curl($url, $data, array('timeout' => 10));
if (self::IS_DEBUG){
print_r($url);
print_r("<br/>");
print_r($res);
}else{
return json_decode($res,true);
}
}
/**
* 锁定基石库存
* @return [type] [description]
*/
public function lockSku($order_id, $skus = array(),$lock_type, $is_pre_sale = false)
{
$datas = array(
'lock_type'=>$lock_type, //库内异常传1
'order_id' => $order_id,
'Items' => $skus,
'is_pre_sale' => $is_pre_sale,
);
$data['type'] = 'sku.lock';
$data['data'] = urlencode(json_encode($datas));
$data['timestamp'] = time();
return self::push($data,'/wmsapi/WebApiLockStock');
}
/**
* 解锁基石库存
* @param [type] $order_id 订单ID
* @param array $skus sku明细 sku-》数量
* @param int $lock_type 锁定类型,库内异常传1
* @param boolean $reduce 是否扣减库存
* @param boolean $reduce_wms 是否请求WMS取消订单
* @return [type] [description]
*/
public function unlockSku($order_id, $skus = array(),$lock_type, $reduce = false, $reduce_wms = false)
{
$datas = array(
'order_id' => $order_id,
'Items' => $skus,
'reduce' => $reduce,
'reduce_wms' => $reduce_wms,
'lock_type'=>$lock_type, //库内异常传1
);
$data['type'] = 'sku.unlock';
$data['data'] = urlencode(json_encode($datas));
$data['timestamp'] = time();
return self::push($data,'/wmsapi/WebApiUnlockStock');
}
/**
* 查询sku最低价格
* @param array $data 查询
*/
public function GetLowestPrice($data = [])
{
// $data = ['10197'=>'GZ1608U102CTF']; //debug
OperationLogModel::log(0,1,'skulower_price_get',0,0,$data,'请求');
$datas['type'] = 'sku.GetLowestPrice';
$datas['data'] = urlencode(json_encode($data));
$datas['timestamp'] = time();
$res = self::push($datas,'/wmsapi/WebApiGetLowestPrice');
if ($res == null || $res == ""){
$res = "";
}
OperationLogModel::log(0,1,'skulower_price_success',0,0,$res,'返回');
return $res;
}
/*
* 查询sku
*/
public function WebApiObGoodsID($data){
$Url=Config('website.FS_API_Url').'WebApiObGoodsID';
$map['data']['arr']=$data;
$key=Config('website.MD5KEY');
$map['AuthSign']=MD5(MD5(http_build_query($map)).$key);
$map['time']=time();
$updata['data']=$map;
$res = curl($Url,http_build_query($updata),1);
$result=json_decode($res,true);
return $result;
}
}
\ No newline at end of file
<?php
namespace App\Model\Server;
use App\map\PreSaleOrderMap;
use App\Model\OperationLogModel;
use League\Flysystem\Exception;
use Request;
use DB;
/* 采购 推送到 wms 公共模型(通过yyc的python接口跳转)
if(empty($res['entity'][0]['Status']) ){
return [20001,'来料通知单撤消失败,请与仓库人员确认来料通知单的处理情况后再作处理',isset($res['entity'][0]['Message'])?$res['entity'][0]['Message']:''];
}
*/
class PurToWmsModel
{
private $SERVICE_URL;
public function __construct()
{
$this->SERVICE_URL = Config('website.WmsServiceUrl');
}
/*
* 关闭来料通知单
*@param string $delivery_sn 来料通知单
*@param int $user_id 用户ID
*@parma int $status 1 关闭 2删除
*/
public function cancelinstockorder($data){
OperationLogModel::log(0,1,'ptw_cancelinstockorder_get',0,0,$data,'通知仓库关闭来料通知单-原始数据');
$dataWms['type'] = 'cancelinstockorder';
$dataWms['from'] = 'purchase';
$dataWms['to'] = 'wms';
$dataWms['Timestamp'] = time();
$dataWms['jsonParas'] = json_encode(['entity' =>$data]);
$result=curl( $this->SERVICE_URL, http_build_query($dataWms), true,false,'');
OperationLogModel::log(0,1,'ptw_cancelinstockorder_get',0,0,$result,'通知仓库关闭来料通知单-返回结果');
return json_decode($result,true);
}
/*
* 采购退料通知wms
*/
public function SupplierReturn($data){
OperationLogModel::log(0,1,'ptw_supplierreturn_get',0,0,$data,'采购退料通知仓库-原始数据');
$dataWms['type'] = 'supplierreturn';
$dataWms['from'] = 'purchase';
$dataWms['to'] = 'wms';
$dataWms['Timestamp'] = time();
$dataWms['jsonParas'] = json_encode(['entity' =>[$data]]);
$result=curl( $this->SERVICE_URL, http_build_query($dataWms), true,false,'');
OperationLogModel::log(0,1,'ptw_supplierreturn_return',0,0,$result,'采购退料通知仓库-返回结果');
return json_decode($result,true);
}
/*
* 取消订单
*/
public function CancelOrder($order_id,$order_type){
OperationLogModel::log(0,1,'ptw_cancelorder_get',0,0,"订单ID:$order_id 订单类型:$order_type ",'采购取消订单通知仓库-原始数据'); //日志
$data = [
'order_id'=>$order_id,
'order_type'=>$order_type, //订单类型 1销售出库 2 采购退料
];
$dataWms['type'] = 'cancelorder';
$dataWms['from'] = 'purchase';
$dataWms['to'] = 'wms';
$dataWms['Timestamp'] = time();
$dataWms['jsonParas'] = json_encode(['entity' =>[$data]]);
$result=curl($this->SERVICE_URL, http_build_query($dataWms), true,false,'');
OperationLogModel::log(0,1,'ptw_cancelorder_return',0,0,"订单ID:$order_id 订单类型:$order_type 返回结果:$result" ,'采购取消订单通知仓库-返回结果'); //日志
return json_decode($result,true);
}
}
......@@ -8,113 +8,52 @@ use DB;
//跟财务接口通讯模型
class ServerFinanceModel
{
private $financeUrl ; //财务网址
const IS_DEBUG = false; //是否调试
public function __construct()
{
$this->financeUrl = Config('website.FinanceUrl');
// $this->financeUrl = 'http://szfinance.ichunt.net';
}
//发送请求
public function push($url,$map){
$financeResult = json_decode(AuthCurl($url, $map, true), true);
private $pur_url ; //采购网址
private $appid ; //APPID
private $key ; //密钥
const IS_DEBUG = 0; //是否调试
public function __construct($appid,$key)
{
$this->pur_url = Config('website.URL_PUR');
// $this->financeUrl = 'http://szfinance.ichunt.net';
$this->appid = $appid;
$this->key = $key;
}
//发送请求
public function push($url,$data,$type = 1){
$data = ExcessEncryption($data,$this->appid,$this->key);
$urls = $this->pur_url.$url;
$res = (curl($urls,$data));
if (self::IS_DEBUG){
print_r($url);
print_r($urls);
print_r("<br/>");
print_r($map);
print_r($data);
print_r("<br/>");
print_r($financeResult);
print_r($res);
die();
}
return $financeResult;
}
//获取可抵扣的收款单列表
public function getFinanceReceive($data,$userId){
$url = $this->financeUrl . '/webapi/apiReceive';
$map['choice'] = 1;
$map['limit'] = $data['limit'];
$map['p'] = $data['p'];
$map['receive_status'] = '1,2';
$map['supplier_id'] = $data['supplier_id'];
return $this->push($url,$map);
if ($type == 1){
echo $res;
exit();
}else{
return json_decode($res,true);
}
}
/*
* 获取某采购单付款情况
* @param int $picking_id 采购ID
* @param int $picking_sn 采购单号
*/
public function getFinancePurchaseInfo($picking_id,$picking_sn){
$url = $this->financeUrl . '/webapi/apiPaymentInfo';
$map['picking_id'] = $picking_id;
$map['picking_sn'] = $picking_sn;
return $this->push($url,$map);
//获取对账单列表
public function accountCheckingList($input){
$url = $this->financeUrl . '/webapi/accountCheckingList';
return $this->push($url,$input);
}
/*
* 对接财务系统,生成收款單
* abnormal_sn:45646 //差异单号
* receive_type:1 //1来料异常,2库内异常 3作废订单 4采购收款
* settle_party:1 //1猎芯 2富开
* supplier_id:342 //供应商ID
* supplier_code:43 //供应商编码
* supplier_name:432 //供应商名称
* currency:1 //币种:1人民币,2美金,3港币,4欧元,5英镑
* settle_amount:432 //结算金额
* create_uid:100 //申请人
* create_name:432432 //申请人名称
* putaway_sn:1 //入库单号
* picking_sn:1 //采购单号
* delivery_sn:1 //来料通知单号
* remark:1 //备注
*/
public function pushReceive($data){
$url = $this->financeUrl . '/webapi/pushReceive';
$map['abnormal_sn'] = $data['abnormal_sn'];
$map['receive_type'] = $data['receive_type'];
$map['settle_party'] = $data['settle_party'];
$map['supplier_id'] = $data['supplier_id'];
$map['supplier_code'] = $data['supplier_code'];
$map['supplier_name'] = $data['supplier_name'];
$map['pay_type'] = $data ? $data['pay_type'] : "";
$map['day_num'] = $data ? $data['day_num'] : "";
$map['currency'] = $data['currency'];
$map['settle_amount'] = $data['settle_amount'];
$map['create_uid'] = $data['create_uid'];
$map['create_name'] = $data['create_name'];
$map['putaway_sn'] = $data['putaway_sn'];
$map['picking_sn'] = $data['picking_sn'];
$map['delivery_sn'] =$data['delivery_sn'];
$map['remark'] = $data['remark'];
return $this->push($url,$map);
//获取对账单列表明细
public function accountCheckingDetail($input){
$url = $this->financeUrl . '/webapi/accountCheckingDetail';
return $this->push($url,$input);
}
/*
*查询此采购单(申请付款中+已付款)总金额
*@param string|array $picking_sn 采购单号
*@return array
*/
public function GetPurPay($picking,$type = 1){
$s = "";
if (is_array($picking)){
foreach ($picking as $k=>$v){
$s .= " '$v',";
}
$s = "in (".rtrim($s,',').")";
}else{
$s = " = '$picking'";
}
$sql = "SELECT
i.picking_sn,
i.picking_id,
SUM(i.pay_amount)AS pay_amount
FROM
lie_payment p,
lie_payment_items i
WHERE
p.payment_id = i.payment_id
AND p.`status` IN(- 1, 1, 2, 3, 7, 10)
AND ".($type == 1 ? 'picking_sn':"picking_id")." $s
GROUP BY picking_sn";
$res = SelectDb('finance',$sql);
return count($res) ? array_column($res,'pay_amount',($type == 1 ? 'picking_sn':"picking_id")) : [];
//对账确定
public function accountChangeChecking($input){
$url = $this->financeUrl . '/webapi/accountChangeChecking';
return $this->push($url,$input);
}
}
\ No newline at end of file
<?php
namespace App\Model\Server;
use Request;
use DB;
//跟采购通讯模型
class ServerPurModel
{
private $pur_url ; //采购网址
private $appid ; //APPID
private $key ; //密钥
const IS_DEBUG = 0; //是否调试
public function __construct($appid,$key)
{
$this->pur_url = Config('website.URL_PUR');
// $this->financeUrl = 'http://szfinance.ichunt.net';
$this->appid = $appid;
$this->key = $key;
}
//发送请求
public function push($url,$data,$type = 1){
$data = ExcessEncryption($data,$this->appid,$this->key);
$urls = $this->pur_url.$url;
$res = (curl($urls,$data));
if (self::IS_DEBUG){
print_r($urls);
print_r("<br/>");
print_r($data);
print_r("<br/>");
print_r($res);
die();
}
if ($type == 1){
echo $res;
exit();
}else{
return json_decode($res,true);
}
}
//获取库存变化列表
public function StockChangeItemsList($data){
return $this->push( '/thridapi/StockChangeItems',$data);
}
//获取订单列表
public function OrderList($data){
return $this->push( '/thridapi/OrderList',$data);
}
//获取订单明细
public function OrderDetail($data){
return $this->push( '/thridapi/OrderDetail',$data);
}
//获取退货列表
public function AbnormalList($data){
return $this->push( '/thridapi/AbnormalList',$data,1);
}
//获取退货明细
public function AbnormalDetail($data){
return $this->push( '/thridapi/AbnormalDetail',$data);
}
}
\ No newline at end of file
<?php
namespace App\Model\Server;
use App\map\PreSaleOrderMap;
use App\Model\AbnormalItemsModel;
use App\Model\AbnormalModel;
use App\Model\OperationLogModel;
use App\Model\PurchaseModel;
use App\Model\Server\ServerFinanceModel;
use App\Model\UserModel;
use League\Flysystem\Exception;
use Request;
use DB;
/*
* wms 推送到采购公共模型
*/
class WmsToPurModel
{
/*
* wms出库(库内异常退货推送到采购)
* @param array $data = "{\"outstock_sn\": \"LX1811010001\",
\"order_id\": \"237894\", //对应异常单id
\"shipping_id\": \"10\",
\"box_weight\": \"115.0000\",
\"express_amount\": \"0.0000\",
\"express_sn\": \"SUR400002492502\",
\"send_time\": \"1541041860\",
\"send_userid\": \"1460\",
\"is_print\": \"False\",
\"warehouse_code\": \"01\",
\"total_rows\": \"1\",
\"detail\": [
{
\"outstock_sn\": \"LX1811010001\",
\"order_id\": \"237894\",
\"rec_id\": \"250194\",
\"goods_id\": \"32937\",
\"goods_price\": \"1.15560\",
\"goods_number\": \"210.0000\"
}
]}";
*/
public function WebApiAbnormalStockReturn($data){
OperationLogModel::log(0,3,'change_abnormal_putaway_get',0,0,$data,'接收','采购退料单回传'); //日志
//接收数据
$param = ['order_id','send_time','detail'];
if (!checkRequire($data,$param)){
return [20001,'缺少参数'.checkRequire($data,$param,2)];
}
$abnormalId = $data['order_id'];
$PurchaseModel = new PurchaseModel();
$UserModel = new UserModel();
$AbnormalModel = new AbnormalModel();
$AbnormalItemsModel = new AbnormalItemsModel();
$ServerFinanceModel = new ServerFinanceModel();
//去重
$detail = [];
foreach ($data['detail'] as $k=>$v){
if (array_key_exists($v['goods_id'],$detail)){
$detail[$v['goods_id']]['goods_number'] += $v['goods_number'];
}else{
$detail[$v['goods_id']] = $v;
}
}
try{
$con = DB::connection('web');
$con->beginTransaction();
#对比出库数量跟申请数量是否一致
$abItems = $AbnormalItemsModel->select("i.sku_id","a.*")->from("abnormal_items as a") ->join("purchase_items as i","a.picking_items_id","=","i.picking_items_id")->where("a.abnormal_id",$abnormalId)->get();
if (!$abItems->count()){
throw new Exception("不存在此订单号");
}
$abItemsArr = $abItems->toArray();
$abItemsGroup = array_column($abItemsArr,null,'sku_id');
foreach ($detail as $a=>$b){
if (array_key_exists($b['goods_id'],$abItemsGroup) === false){
throw new Exception("不存在此sku_id".$b['goods_id']);
}else{
if ($abItemsGroup[$b['goods_id']]['real_number'] != $b['goods_number']){
throw new Exception("此商品:".$b['goods_id']."退货数量跟申请数量不一致");
}
}
}
#扣减基石库存
$unlockSku = array_column($abItemsArr,'real_number','sku_id');
$unlockRes = (new FoostoneModel())->unlockSku($abnormalId,$unlockSku,1,true); //扣减库存
if ($unlockRes['errcode'] != 0) {
throw new Exception("基石扣减库存失败:order_id:$abnormalId sku_id:$unlockSku msg:".$unlockRes['errmsg']);
}
#如果存在收款,通知财务,调用财务收款接口
$allWithdrawAmount = $AbnormalItemsModel->where("abnormal_id",$abnormalId)->sum("withdraw_amount");
$abInfo = $AbnormalModel->where("abnormal_id",$abnormalId)->first();
if ($allWithdrawAmount > 0) {
#查询供应商
$su = $PurchaseModel->where("picking_sn", $abInfo['picking_sn'])->select("supplier_id","supplier_code","supplier_name","currency","pay_type","day_num")->first();
//查用户名
$userName = $UserModel->FinduserInfoName($abInfo['create_uid']);
#对接财务系统,通知收款
$map['abnormal_sn'] = $abInfo->abnormal_sn;
$map['receive_type'] = $abInfo->abnormal_type;
$map['settle_party'] = 1;
$map['supplier_id'] = $su ? $su['supplier_id'] : "";
$map['supplier_code'] = $su ? $su['supplier_code'] : "";
$map['supplier_name'] = $su ? $su['supplier_name'] : "";
$map['pay_type'] = $su ? $su['pay_type'] : "";
$map['day_num'] = $su ? $su['day_num'] : "";
$map['currency'] = $su ? $su['currency'] : "";
$map['settle_amount'] = $allWithdrawAmount;
$map['create_uid'] = $abInfo['create_uid'];
$map['create_name'] = $userName ? $userName : "";
$map['putaway_sn'] = $abInfo->putaway_sn;
$map['picking_sn'] = $abInfo->picking_sn;
$map['delivery_sn'] = $abInfo->delivery_sn;
$map['remark'] = $abInfo->remark;
$finaneResult =$ServerFinanceModel->pushReceive($map);
if ($finaneResult['err_code'] > 0) {
throw new Exception("推送财务收款接口失败:".$finaneResult);
}
}
#获取出库最新汇率
$abnormalInfo = $AbnormalModel->where("abnormal_id",$abnormalId)->first();
$HLCurrency=Config('fixed.HLCurrency');
if($abnormalInfo['currency']==1){
$exchange_rate = 1;
}else{
$exchange_rate = webserver($HLCurrency[$abnormalInfo['currency']]);
if(!$exchange_rate || !$exchange_rate>0){
throw new Exception("汇率获取失败");
}
}
#最后更改状态为已完成+更新汇率
$pan = $AbnormalModel->where("abnormal_id",$abnormalId)->update(['status'=>4,'exchange_rate'=>$exchange_rate,'outstock_time'=>time()]);
OperationLogModel::log(0,3,'change_abnormal_putaway_success',0,0,$data,'成功','采购退料单回传'); //日志
$con->commit();
return [0, '成功'];
}catch (\Exception $e) {
$con->rollBack();
OperationLogModel::log(0,3,'change_abnormal_putaway_error',0,0,$data,$e->getMessage(),'采购退料单回传-失败'); //日志
return [20003, '失败:'.$e->getMessage()];
}
}
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ class SupplierAccountModel extends Model
return [1003,'密码错误'];
}
//用户详情
$supplierInfo = DB::connection("web")->table("supplier_channel")->where("supplier_id",$account['supplier_id'])->first();
$supplierInfo = DB::connection("pur")->table("supplier_channel")->where("supplier_id",$account['supplier_id'])->first();
//用户角色
$yunxinCon = DB::connection("yunxin");
$roleInfo = $yunxinCon->table("auth_role_access")->where("account_id",$account['id'])->first();
......@@ -52,11 +52,13 @@ class SupplierAccountModel extends Model
'supplier_id'=>$account['supplier_id'],
'supplier_name'=>$supplierInfo['supplier_name'],
'account_id'=>$account['id'],
'appid'=>$account['appid'],
'key'=>$account['key'],
'role_id'=>$roleInfo['role_id'],
];
try{
$con = DB::connection('web');
$con = DB::connection('yunxin');
$con->beginTransaction();
#登录信息写入缓存
$key = md5($account_name.$code.time());
......
......@@ -91,20 +91,6 @@ return [
'prefix' => '',
'schema' => 'public',
],
'web' => [
'driver' => 'mysql',
'host' => env('WEB_DB_HOST', 'localhost'),
'port' => env('WEB_DB_PORT', '3306'),
'database' => env('WEB_DB_DATABASE', 'forge'),
'username' => env('WEB_DB_USERNAME', 'forge'),
'password' => env('WEB_DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
'engine' => null,
],
'self'=>[
'driver' => 'mysql',
'host' => env('DB_SELF_HOST', ''),
......@@ -153,6 +139,18 @@ return [
'prefix' => 'lie_',
'strict' => false,
],
'pur' => [
'driver' => 'mysql',
'host' => env('DB_HOST_PUR', ''),
'database' => env('DB_DATABASE_PUR', ''),
'username' => env('DB_USERNAME_PUR', ''),
'password' => env('DB_PASSWORD_PUR', ''),
'port' => env('DB_PORT_PUR', 3306),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'lie_',
'strict' => false,
],
'rabbitmq' => [
'driver' => 'rabbitmq',
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment