using Operater.DAL;
|
using Operater.DTO.System;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using CommonUtil;
|
using YouZanSDKStandard.Api.Request;
|
using YouZanSDKStandard.Api;
|
using Operater.DbModel;
|
|
namespace Operater.Service.System
|
{
|
public class SendGoodsService : ISendGoodsService
|
{
|
/// <summary>
|
/// 有赞发货
|
/// </summary>
|
/// <param name="request"></param>
|
/// <returns></returns>
|
public YzSendGoodsResponse YzSendGoods(YzSendGoodsRequest request)
|
{
|
YzSendGoodsResponse response = new YzSendGoodsResponse()
|
{
|
IsSuccess = false
|
};
|
try
|
{
|
//判断是否发货过
|
var relatio = new TradeCreateRelationDAL().GetById(request.YzOid);
|
if(relatio.IsNull())
|
{
|
response.ErrorMsg = "该子订单对应的1688订单未发货";
|
return response;
|
}
|
if (relatio.YzIssendgoods == 1)
|
{
|
response.ErrorMsg = "该子订单已经发货";
|
return response;
|
}
|
//获取1688物流信息
|
var aliLogistics = new AliLogisticsDAL().GetById(relatio.AliOid);
|
if (aliLogistics.IsNull() || aliLogistics.AliOid.IsNullOrEmpty())
|
{
|
response.ErrorMsg = "获取1688物流信息失败";
|
return response;
|
}
|
//获取有赞发货的物流
|
var expressList = new AliExpressDAL().ListGet(t=>t.ComNo== aliLogistics.CpCode);
|
var express = expressList[0];
|
YouZanLogisticsConfirmRequest yzReq = new YouZanLogisticsConfirmRequest()
|
{
|
tid = relatio.YzTid,
|
out_stype = express.YzId.ToString(),
|
out_sid = aliLogistics.MailNo,
|
is_no_express = 0,
|
oids = request.YzOid
|
};
|
var yzRsp = YouZanClient.Execute(yzReq, request.YzToken);
|
LogUtil.Info("Oid:" + request.YzOid + ",req:" + JSONUtil.ObjectToJson(yzRsp), "有赞发货请求");
|
if (yzRsp.IsNull() || !yzRsp.success)
|
{
|
response.ErrorMsg = "有赞发货失败:" + (yzRsp.IsNull() ? "返回null" : yzRsp.message);
|
return response;
|
}
|
YzOrderinfo yzOrderinfo = new YzOrderinfo()
|
{
|
YzGoodsStatus = 1
|
};
|
new YzOrderinfoDAL().Update(yzOrderinfo,i => new{ i.YzGoodsStatus}, t => t.Oid == request.YzOid);
|
|
response.IsSuccess = true;
|
return response;
|
}
|
catch (Exception e)
|
{
|
response.ErrorMsg = e.ToString();
|
return response;
|
}
|
}
|
}
|
}
|