Commit 40d70eb2 authored by 黄奎's avatar 黄奎
parents e5e0d84d 311e66a9
......@@ -573,6 +573,17 @@ namespace Mall.Common
}
}
/// <summary>
/// 电商erp订单 原路退款
/// </summary>
public static string ZYRefundFinanceApi
{
get
{
return ReadConfigKey("ZYRefundFinanceApi");
}
}
/// <summary>
/// 微信支付结算率0.60%
/// </summary>
......
......@@ -24,6 +24,7 @@ using Mall.Repository.User;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.SS.Formula.Functions;
using VT.FW.DB;
......@@ -7173,8 +7174,13 @@ namespace Mall.Module.Product
{
if (tenantId == 1)
{
//2020-07-03 屏蔽 改每日自动生成
//OrderRefundFinanceModule(model, tenantId, mallBaseId);
var omdoel = goods_OrderRepository.GetEntity(model.OrderId);
if (omdoel.OrderSource == UserSourceEnum.ERP)
{
//2020-07-03 屏蔽 改每日自动生成
//2020-09-15 电商erp订单 财务单据生成
OrderRefundFinanceModule(model, tenantId, mallBaseId);
}
}
goods_OrderAfterSaleLogRepository.Insert(new RB_Goods_OrderAfterSaleLog()
{
......@@ -7201,13 +7207,6 @@ namespace Mall.Module.Product
try
{
decimal Money = dmodel.Refund ?? 0;
//decimal Rate = Convert.ToDecimal(Config.SettlementRate);
//decimal Fee = 0;
//if (Rate > 0)
//{
// Fee = Math.Round(Money * Rate / 1000, 2, MidpointRounding.AwayFromZero);
// Money -= Fee;
//}
//查询用户
var umodel = member_UserRepository.GetEntity(dmodel.UserId);
if (umodel == null) { return false; }
......@@ -7230,7 +7229,17 @@ namespace Mall.Module.Product
Remark = "订单号:" + omodel.OrderNo + "售后单号:" + (dmodel.ReOrderNo ?? "暂无") + " " + dstr
}
};
List<RB_ECFinanceId_Relation> ECList = new List<RB_ECFinanceId_Relation>();
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = dmodel.OrderId ?? 0 });
foreach (var qitem in dlist)
{
ECList.Add(new RB_ECFinanceId_Relation()
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.Id
});
}
item.IsPublic = 8;//默认原路退款
var financeObj = new
{
......@@ -7244,11 +7253,12 @@ namespace Mall.Module.Product
RB_Branch_Id = Config.ExpendBranchId,
TemplateId = item.WorkFlowId,
OrderSource = 16,
OtherType = 12,
OtherType = 22,
ReFinanceId = dmodel.ReOrderId,
Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据",
Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + "自动生成财务单据(erp订单)",
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......@@ -7261,7 +7271,8 @@ namespace Mall.Module.Product
if (apir.resultCode == 1)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Goods_OrderAfterSale.ReRemark), dmodel.ReRemark +" 自动生成财务退款单据:"+ apir.data.ToString()}
{ nameof(RB_Goods_OrderAfterSale.ReRemark), dmodel.ReRemark +" 自动生成财务退款单据:"+ apir.data.ToString()},
{ nameof(RB_Goods_OrderAfterSale.FinanceId), Convert.ToInt32(apir.data.ToString())}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
......@@ -7459,6 +7470,39 @@ namespace Mall.Module.Product
return false;
}
/// <summary>
/// 电商erp订单退款
/// </summary>
/// <param name="orderId"></param>
/// <param name="financeId"></param>
/// <returns></returns>
public bool SetMallOrderSalesTheWayRefund(int orderId, int? financeId)
{
var financeObj = new
{
OrderId = orderId,
FinanceId = financeId ?? 0
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
{
msg = sign
};
string apiResult = Mall.Common.Plugin.HttpHelper.HttpPost(Config.ZYRefundFinanceApi, JsonHelper.Serialize(resultInfo), "");
JObject parmsJob = JObject.Parse(apiResult);
string resultCode = parmsJob.GetStringValue("resultCode");
if (resultCode == "1")
{
return true;
}
else
{
LogHelper.Write("SetMallOrderSalesTheWayRefund失败,orderId:" + orderId + ",financeId:" + financeId);
return false;
}
}
/// <summary>
/// 售后订单 发货
/// </summary>
......@@ -7962,10 +8006,11 @@ namespace Mall.Module.Product
});
}
goods_OrderRepository.DBSession.Commit();
if (flag && type == 1 && tenantId == 1)
if (flag && type == 1 && tenantId == 1 && omodel.OrderSource == UserSourceEnum.ERP)
{
//同意 创建财务单据 屏蔽 改为每日自动创建
//OrderRefundFinanceModule(omodel);
// 2020 -09-15 ld erp订单 需点击创建财务单据
OrderRefundFinanceModule(omodel);
}
return flag;
}
......@@ -8217,12 +8262,13 @@ namespace Mall.Module.Product
}
}
goods_OrderRepository.DBSession.Commit();
if (flag && tenantId == 1)
if (flag && tenantId == 1 && omodel.OrderSource == UserSourceEnum.ERP)
{
if (omodel.OrderStatus != OrderStatusEnum.NonPayment)
{
//同意 创建财务单据 屏蔽 改为每日自动创建
//OrderRefundFinanceModule(omodel, true);
//erp订单 需创建财务单据 2020-09-15
OrderRefundFinanceModule(omodel, true);
}
}
return flag;
......@@ -8244,22 +8290,15 @@ namespace Mall.Module.Product
{
var flag = false;
try
{
//decimal Rate = Convert.ToDecimal(Config.SettlementRate);
{
decimal Money = omodel.Income ?? 0;
//decimal Fee = 0;
//if (Rate > 0) {
// Fee = Math.Round(Money * Rate / 1000, 2, MidpointRounding.AwayFromZero);
// Money -= Fee;
//}
//查询用户
var umodel = member_UserRepository.GetEntity(omodel.UserId);
if (umodel == null) { return false; }
//先查询规则
var financeConfigurineList = financeConfigurineRepository.GetList(new Model.Extend.Finance.RB_Finance_Configurine_Extend { Type = 3 });
//string dstr = "客人付款:" + (omodel.Income ?? 0) + "金额,退款:" + (omodel.Income ?? 0) + ",手续费:" + Fee;
string dstr = "客人付款:" + (omodel.Income ?? 0) + "金额,退款:" + (omodel.Income ?? 0);
if (financeConfigurineList != null && financeConfigurineList.Any())
{
......@@ -8276,10 +8315,20 @@ namespace Mall.Module.Product
};
item.IsPublic = 8;//默认原路退款
string Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + " 自动生成财务单据";
string Remark = "名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + " 自动生成财务单据(ERP下单)";
if (IsForcedToCancel)
{
Remark = "后台强制取消该订单,用户名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + " 自动生成财务单据";
Remark = "后台强制取消该订单,用户名称:" + umodel.Name + "(" + umodel.Id + ")" + " " + System.DateTime.Now.ToString("yyyy年MM月dd日") + " 自动生成财务单据(ERP下单)";
}
List<RB_ECFinanceId_Relation> ECList = new List<RB_ECFinanceId_Relation>();
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = omodel.OrderId });
foreach (var qitem in dlist)
{
ECList.Add(new RB_ECFinanceId_Relation()
{
ECOrderId = qitem.OrderId,
ECOrderDetailId = qitem.Id
});
}
var financeObj = new
{
......@@ -8293,11 +8342,12 @@ namespace Mall.Module.Product
RB_Branch_Id = Config.ExpendBranchId,
TemplateId = item.WorkFlowId,
OrderSource = 16,
OtherType = 14,
OtherType = 24,
ReFinanceId = omodel.OrderId,
Remark = Remark,
Remark,
detailList,
RB_Depart_Id = Config.ExpendDepartment
RB_Depart_Id = Config.ExpendDepartment,
ECOrderList = ECList
};
string sign = EncryptionHelper.AesEncrypt(JsonHelper.Serialize(financeObj), Config.FinanceKey);
var resultInfo = new
......
......@@ -203,5 +203,68 @@ INNER JOIN rb_member_user mu on mu.Id=oas.UserId
string sql = $@"SELECT oas.* FROM rb_goods_orderaftersale oas {where} order by oas.ReOrderId desc";
return Get<RB_Goods_OrderAfterSale_Extend>(sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Goods_OrderAfterSale_Extend> GetList_V2(RB_Goods_OrderAfterSale_Extend dmodel, bool IsNormal = true)
{
string where = $" where 1=1 and oas.{nameof(RB_Goods_OrderAfterSale.Status)}=0 and o.OrderSource<>6";
if (IsNormal)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)} <> {(int)Common.Enum.Goods.OrderAfterSaleStatusEnum.Rejected}";
}
if (dmodel.TenantId > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.UserId > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.UserId)}={dmodel.UserId}";
}
if (dmodel.OrderId > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.OrderId)}={dmodel.OrderId}";
}
if (dmodel.OrderDetialId > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.OrderDetialId)}={dmodel.OrderDetialId}";
}
if (dmodel.Type > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.Type)}={dmodel.Type}";
}
if (dmodel.ReOrderStatus > 0)
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.ReOrderStatus)}={(int)dmodel.ReOrderStatus}";
}
if (!string.IsNullOrEmpty(dmodel.ReOrderNo))
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.ReOrderNo)} like '%{dmodel.ReOrderNo}%'";
}
if (!string.IsNullOrEmpty(dmodel.OrderDetailIds))
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.OrderDetialId)} in({dmodel.OrderDetailIds})";
}
if (!string.IsNullOrEmpty(dmodel.FStartTime))
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.FinishTime)}>='{dmodel.FStartTime}'";
}
if (!string.IsNullOrEmpty(dmodel.FEndTime))
{
where += $" and oas.{nameof(RB_Goods_OrderAfterSale.FinishTime)}<='{dmodel.FEndTime} 23:59:59'";
}
string sql = $@"SELECT oas.* FROM rb_goods_orderaftersale oas
INNER JOIN rb_goods_order o on oas.OrderId=o.OrderId
{where} order by oas.ReOrderId desc";
return Get<RB_Goods_OrderAfterSale_Extend>(sql).ToList();
}
}
}
......@@ -733,7 +733,7 @@ GROUP BY oc.OrderId";
public List<RB_Goods_Order_Extend> GetOrderRefunedCreateList(int tenantId, int mallBaseId, string startTime, string endTime)
{
string sql = $@"SELECT * FROM rb_goods_order o
WHERE o.TenantId={tenantId} and o.MallBaseId={mallBaseId} and o.OrderStatus = 7 AND o.PaymentTime IS NOT NULL AND DATE_FORMAT(o.PaymentTime,'%Y-%m-%d') <> DATE_FORMAT(o.CancelTime,'%Y-%m-%d') AND o.CancelTime>='{startTime}' AND o.CancelTime <'{endTime}'";
WHERE o.TenantId={tenantId} and o.MallBaseId={mallBaseId} and o.OrderStatus = 7 and o.OrderSource <> 6 AND o.PaymentTime IS NOT NULL AND DATE_FORMAT(o.PaymentTime,'%Y-%m-%d') <> DATE_FORMAT(o.CancelTime,'%Y-%m-%d') AND o.CancelTime>='{startTime}' AND o.CancelTime <'{endTime}'";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
......@@ -1493,7 +1493,7 @@ GROUP BY od.GoodsId,o.OrderId
/// <returns></returns>
public List<RB_Goods_Order_Extend> GetCanCancelOrderList(int cancelTime, int t, int m)
{
string sql = $@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =1 and OrderSource <> 6 and DATE_ADD(CreateDate,INTERVAL {cancelTime} MINUTE) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
string sql = $@"SELECT OrderId,UserId,OrderNo,OrderSource,CouponsIds FROM rb_goods_order where TenantId ={t} and MallBaseId ={m} and `Status`=0 and OrderStatus =1 and DATE_ADD(CreateDate,INTERVAL {cancelTime} MINUTE) < '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
return Get<RB_Goods_Order_Extend>(sql).ToList();
}
......
......@@ -663,7 +663,7 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("该订单已无法取消");
}
int IsNormalServer = Convert.ToInt32(new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("IsNormalServer").Value);
if (IsNormalServer == 1 && omodel.OrderStatus == OrderStatusEnum.WaitSendGoods)
if (IsNormalServer == 1 && omodel.OrderStatus == OrderStatusEnum.WaitSendGoods && omodel.OrderSource != UserSourceEnum.ERP)
{
//获取小程序信息
var mallModel = orderModule.GetMiniProgramExtend(req.MallBaseId);
......@@ -881,7 +881,7 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed("该订单未申请取消该订单");
}
int IsNormalServer = Convert.ToInt32(new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("IsNormalServer").Value);
if (Type == 1 && IsNormalServer == 1)
if (Type == 1 && IsNormalServer == 1 && omodel.OrderSource != UserSourceEnum.ERP)
{
//获取小程序信息
var mallModel = orderModule.GetMiniProgramExtend(req.MallBaseId);
......@@ -2401,6 +2401,7 @@ namespace Mall.WebApi.Controllers.MallBase
x.ReOrderStatus,
ReOrderStatusName = x.ReOrderStatus.GetEnumName(),
x.ReRemark,
x.FinanceId,
x.TenantId,
x.MallBaseId,
CreateDate = x.CreateDate.HasValue ? x.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
......@@ -2654,7 +2655,7 @@ namespace Mall.WebApi.Controllers.MallBase
var omodel = orderModule.GetOrderInfo(ReModel.OrderId ?? 0);
int IsNormalServer = Convert.ToInt32(new ConfigurationBuilder().Add(new JsonConfigurationSource { Path = "appsettings.json" }).Build().GetSection("IsNormalServer").Value);
if (IsNormalServer == 1)
if (IsNormalServer == 1 && omodel.OrderSource != UserSourceEnum.ERP)
{
//获取小程序信息
var mallModel = orderModule.GetMiniProgramExtend(req.MallBaseId);
......@@ -2698,6 +2699,25 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.Failed();
}
}
else if (IsNormalServer == 1 && omodel.OrderSource == UserSourceEnum.ERP) {
bool refundflag = orderModule.SetMallOrderSalesTheWayRefund(omodel.OrderId, ReModel.FinanceId);
if (refundflag)
{
bool flag = orderModule.SetOrderAfterSaleForRefunds(omodel, ReOrderId, Refund, "", req.TenantId, req.MallBaseId, Common.Enum.Goods.OrderPayTypeEnum.WeChatPay, "", "", "", "");
if (flag)
{
return ApiResult.Success("");
}
else
{
return ApiResult.Failed();
}
}
else {
LogHelper.Write("调用erp退款接口失败");
return ApiResult.Failed();
}
}
else
{
bool flag = orderModule.SetOrderAfterSaleForRefunds(omodel, ReOrderId, Refund, "", req.TenantId, req.MallBaseId, Common.Enum.Goods.OrderPayTypeEnum.WeChatPay, "", "", "", "");
......
......@@ -45,8 +45,9 @@
"ExpendDepartment": 331,
"RebornDMC": "reborn_dmc",
"PropertyDB": "test_property",
"IncomeFinanceApi": "http://testapi.oytour.com/api/Mall/InsertFinanceBatchForMallIn",
"PaymentFinanceApi": "http://testapi.oytour.com/api/Mall/InsertFinanceBatchForMallOut",
"IncomeFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallIn",
"PaymentFinanceApi": "http://192.168.2.16:8083/api/Mall/InsertFinanceBatchForMallOut",
"ZYRefundFinanceApi": "http://192.168.2.16:8083/api/Mall/SetMallOrderSalesTheWayRefund",
"PropertyApi": "http://192.168.2.16:8087/api/ECWorkFlow/SetECSuppliesStockInFlow",
"FinanceKey": "FinanceMallInsertToERPViitto2020",
"SettlementRate": "0.60",
......@@ -56,7 +57,7 @@
"Port": 5672,
"UserName": "guest",
"Password": "viitto2019"
},
},
"RedisSetting": {
"RedisServer": "47.96.23.199",
"RedisPort": "6379",
......
......@@ -2090,7 +2090,7 @@ and DATE_FORMAT(b.PaymentTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') A
//查询所有的退款
var olist = goods_OrderRepository.GetOrderRefunedCreateList(item.TenantId, item.MallBaseId, startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd"));
//查询所有的售后退款
var afterlist = goods_OrderAfterSaleRepository.GetList(new RB_Goods_OrderAfterSale_Extend() { FStartTime = startDate.ToString("yyyy-MM-dd"), FEndTime = endDate.AddDays(-1).ToString("yyyy-MM-dd"), TenantId = item.TenantId, MallBaseId = item.MallBaseId, Type = 1, ReOrderStatus = OrderAfterSaleStatusEnum.Completed });
var afterlist = goods_OrderAfterSaleRepository.GetList_V2(new RB_Goods_OrderAfterSale_Extend() { FStartTime = startDate.ToString("yyyy-MM-dd"), FEndTime = endDate.AddDays(-1).ToString("yyyy-MM-dd"), TenantId = item.TenantId, MallBaseId = item.MallBaseId, Type = 1, ReOrderStatus = OrderAfterSaleStatusEnum.Completed });
if (olist.Any() || afterlist.Any())
{
OrderRefundFinanceModule(olist, afterlist);
......
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 to comment