Commit 9ada5e23 by 泽锋 李

新增退货单推送

parent f8c62d49
......@@ -290,5 +290,50 @@ namespace AutoTurnOver.DB
throw new Exception("供应商 list 接口异常: " + ex.StackTrace);
}
}
/// <summary>
/// 抓取sku 刊登状态
/// </summary>
/// <returns></returns>
public static void PushSupplierReturnSkuInfo(List<api_distribution_return_order_push_input_dto> datas)
{
try
{
//查询采购建议明细
string url = ConfigHelper.GetValue("SupplierReturnSkuInfo");
string resultStr = HttpHelper.Request(url, RequestType.POST, datas.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<api_distribution_return_order_push_response_dto>();
if (result == null)
{
throw new Exception("无库系统接口未响应");
}
else
{
if (result.statusCode != 200)
{
throw new Exception(result.message);
}
else
{
if (result.result == null)
{
throw new Exception("无库系统接口未响应");
}
else
{
if (!result.result.isSucceeded)
{
throw new Exception(result.result.message);
}
}
}
}
}
catch (Exception ex)
{
throw new Exception("无库系统 退货单推送接口异常: " + ex.Message);
throw new Exception("无库系统 退货单推送接口异常: " + ex.StackTrace);
}
}
}
}
......@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoTurnOver.Utility;
using System.Transactions;
namespace AutoTurnOver.DB
{
......@@ -67,7 +68,8 @@ namespace AutoTurnOver.DB
suppliers_id = itemSku.suppliers_id,
suppliers_name = itemSku.suppliers_name,
warehouse_code = itemSku.warehouse_code,
warehouse_name = itemSku.warehouse_name
warehouse_name = itemSku.warehouse_name,
approval_date = new DateTime(1991, 1, 1)
};
conn.Insert(new_data);
}
......@@ -176,7 +178,7 @@ t1.*,
( case when t5.`status`=0 or t5.`status` is null then '监控中' else '停止监控' end ) as 'monitor_status_str'
from dc_auto_return_goods_sku as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on dat.bailun_sku = t5.bailun_sku and dat.warehouse_code = t5.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1 = 1 ";
DynamicParameters parameters = new DynamicParameters();
if (m.monitor_status != null)
......@@ -184,7 +186,8 @@ where 1 = 1 ";
if (m.monitor_status == 1)
{
sql += " and t5.`status`=1 ";
}else if (m.monitor_status == 2)
}
else if (m.monitor_status == 2)
{
sql += " and ( t5.`status`=0 or t5.`status` is null ) ";
}
......@@ -193,7 +196,7 @@ where 1 = 1 ";
{
sql += " and t1.create_date>=@btime ";
parameters.Add("btime", m.btime.Value.ToDayHome());
}
}
if (m.etime != null)
{
sql += " and t1.create_date<=@etime ";
......@@ -203,7 +206,8 @@ where 1 = 1 ";
{
sql += " and t2.hq_type=@warehousetype";
parameters.Add("warehousetype", m.warehousetype);
}if (!string.IsNullOrWhiteSpace(m.sku))
}
if (!string.IsNullOrWhiteSpace(m.sku))
{
sql += " and t1.bailun_sku=@bailun_sku";
parameters.Add("bailun_sku", m.sku);
......@@ -226,7 +230,7 @@ where 1 = 1 ";
{
sql += " and t1.status=" + m.status;
}
if (m.oms_out_status !=null)
if (m.oms_out_status != null)
{
sql += " and t1.oms_out_status=" + m.oms_out_status;
}
......@@ -242,12 +246,146 @@ where 1 = 1 ";
return obj.AsList();
}
catch (Exception)
catch (Exception ex)
{
return list;
}
}
/// <summary>
/// 批量审批
/// </summary>
/// <param name="input_data"></param>
/// <param name="user"></param>
public static void BatchApproval(batch_approval_input_dto input_data, UserData user)
{
_connection.Execute(" update dc_auto_return_goods_sku set `status`=@status,approval_date=now() where `status`=0 and id in @ids", new
{
status = input_data.status,
ids = input_data.ids.Split(',').Select(s => int.Parse(s)).ToList(),
approval_remarks = input_data.approval_remarks
});
}
/// <summary>
/// 批量推送
/// </summary>
/// <param name="m"></param>
public static void BatchPush(dc_auto_return_goods_sku_search_dto m)
{
int total = 0;
m.status = 1;
var datas = SkuPage(m, 0, int.MaxValue, ref total);
if (datas == null || datas.Count <= 0)
{
throw new Exception("当前查询条件下,没有审批通过的数据");
}
var order_list = GenerateOrder(datas);
try
{
ApiUtility.PushSupplierReturnSkuInfo(order_list.Select(s => new Models.ApiDto.api_distribution_return_order_push_input_dto
{
returnDate = s.order_data.date,
returnOrderNo = s.order_data.order_no,
returnWarehouse = s.order_data.warehouse_name,
returnWarehouseCode = s.order_data.warehouse_code,
supplierId = s.order_data.suppliers_id,
skuList = s.skus.Select(v => new Models.ApiDto.api_distribution_return_order_push_input_dto.sku_dto
{
skuCode = v.bailun_sku,
skuReturn = v.quantity,
skuReturnMonry = v.amount
}).ToList()
}).ToList());
// 推送成功,修改状态
_connection.Execute(" update dc_auto_return_goods_order set no_library_push_msg='成功',no_library_push_date=now(),no_library_push_status=1 where id in @ids ", new { ids = order_list.Select(s => s.order_data.id) });
_connection.Execute(" update dc_auto_return_goods_sku set no_library_sys_push_status=1 where order_id in @order_ids ", new { order_ids = order_list.Select(s => s.order_data.id) });
}
catch (Exception ex)
{
// 推送成功,修改状态
_connection.Execute(" update dc_auto_return_goods_order set no_library_push_msg=@no_library_push_msg,no_library_push_date=now(),no_library_push_status=1 where id in @ids ", new { ids = order_list.Select(s => s.order_data.id),no_library_push_msg = ex.Message });
}
}
/// <summary>
/// 生成订单
/// </summary>
public static List<order_list_dto> GenerateOrder(List<dc_auto_return_goods_sku_dto> datas)
{
List<order_list_dto> order_list = new List<order_list_dto>();
using (var conn = MyMySqlConnection._connection)
{
conn.Open();
using (var t = conn.BeginTransaction())
{
foreach (var item in datas.GroupBy(s => new { s.suppliers_id, s.suppliers_name, s.warehouse_code, s.warehouse_name }))
{
var sup_data = conn.QueryFirstOrDefault<dc_base_supplier>(" select * from dc_base_supplier where sup_value=@sup_value ", new { sup_value = item.Key.suppliers_id });
var new_order_data = new dc_auto_return_goods_order
{
warehouse_name = item.Key.warehouse_name,
warehouse_code = item.Key.warehouse_code,
suppliers_name = item.Key.suppliers_name,
suppliers_id = item.Key.suppliers_id,
companyaddress = sup_data.companyaddress,
contactname = sup_data.contactname,
contactphone = sup_data.contactphone,
date = DateTime.Now,
oms_push_status = 0,
no_library_push_status = 0
};
// 计算单号
// 查询当前最大单号
var max_order_no = conn.QueryFirstOrDefault<string>(" select dc_auto_return_goods_order from dc_auto_return_goods_order order by id desc limit 1 ");
var number_str = "001";
if (!string.IsNullOrWhiteSpace(max_order_no))
{
// 提取流水号
var str_list = max_order_no.Split('-');
number_str = str_list[str_list.Length - 1];
}
new_order_data.order_no = $"{sup_data.city}-{sup_data.short_name}-{new_order_data.date.ToString("yyyyMMdd")}-退-{number_str}";
var new_order_id = conn.Insert(new_order_data, t) ?? 0;
order_list_dto order_list_item = new order_list_dto() { skus = new List<dc_auto_return_goods_order_sku>() };
new_order_data.id = new_order_id;
order_list_item.order_data = new_order_data;
foreach (var itemSku in item.AsEnumerable())
{
var new_sku_data = new dc_auto_return_goods_order_sku
{
order_id = new_order_id,
amount = itemSku.stock_amount,
bailun_sku = itemSku.bailun_sku,
quantity = (int)itemSku.stock
};
new_sku_data.id = conn.Insert(new_sku_data, t)??0;
order_list_item.skus.Add(new_sku_data);
}
conn.Execute(" update dc_auto_return_goods_sku set order_id=@order_id where id in @ids ", new { order_id = new_order_id, ids = item.Select(s=>s.id).ToList() },t);
}
t.Commit();
}
}
return order_list;
}
public class order_dto
{
public DateTime paid_time { get; set; }
......
......@@ -58,6 +58,7 @@ namespace AutoTurnOver.DB
companyaddress = item.companyaddress??"",
contactname = item.contactname??"",
contactphone = item.contactphone??"",
short_name = item.short_name ?? "",
city = item.city??""
};
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// 无库系统订单推送
/// </summary>
public class api_distribution_return_order_push_input_dto
{
public int supplierId { get; set; }
/// <summary>
/// 退货单号
/// </summary>
public string returnOrderNo { get; set; }
/// <summary>
/// 仓库名
/// </summary>
public string returnWarehouse { get; set; }
public string returnWarehouseCode { get; set; }
/// <summary>
/// 时间
/// </summary>
public DateTime returnDate { get; set; }
public List<sku_dto> skuList { get; set; }
public class sku_dto
{
public string skuCode { get; set; }
/// <summary>
/// 退货数
/// </summary>
public int skuReturn { get; set; }
/// <summary>
/// 退货金额
/// </summary>
public decimal skuReturnMonry { get; set; }
}
}
public class api_distribution_return_order_push_response_dto
{
public int statusCode { get; set; }
public string message { get; set; }
public result_dto result { get; set; }
public class result_dto
{
public bool isSucceeded { get; set; }
public string message { get; set; }
}
}
}
......@@ -18,6 +18,7 @@ namespace AutoTurnOver.Models.ApiDto
public string companyaddress { get; set; }
public string contactname { get; set; }
public string contactphone { get; set; }
public string short_name { get; set; }
public string city { get; set; }
public int value { get; set; }
/// <summary>
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class batch_approval_input_dto
{
public string ids { get; set; }
public int status { get; set; }
public string approval_remarks { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_auto_return_goods_order
{
public int id { get; set; }
public string order_no { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public int suppliers_id { get; set; }
public string suppliers_name { get; set; }
public string companyaddress { get; set; }
public string contactname { get; set; }
public string contactphone { get; set; }
public DateTime date { get; set; }
public int oms_push_status { get; set; }
public int no_library_push_status { get; set; }
public string oms_push_msg { get; set; }
public string no_library_push_msg { get; set; }
public DateTime? oms_push_date { get; set; }
public DateTime? no_library_push_date { get; set; }
}
public class dc_auto_return_goods_order_sku
{
public int id { get; set; }
public int order_id { get; set; }
public string bailun_sku { get; set; }
public int quantity { get; set; }
public decimal amount { get; set; }
}
public class order_list_dto
{
public dc_auto_return_goods_order order_data { get; set; }
public List<dc_auto_return_goods_order_sku> skus { get; set; }
}
}
......@@ -8,6 +8,11 @@ namespace AutoTurnOver.Models
{
public int id { get; set; }
public string bailun_sku { get; set; }
public int order_id { get; set; }
/// <summary>
/// 审批时间
/// </summary>
public DateTime approval_date { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public int config_id { get; set; }
......
......@@ -26,6 +26,7 @@ namespace AutoTurnOver.Models
public string companyaddress { get; set; }
public string contactname { get; set; }
public string contactphone { get; set; }
public string short_name { get; set; }
public string city { get; set; }
}
}
......@@ -11,5 +11,14 @@ namespace AutoTurnOver.Services
{
return DB.dc_auto_return_goods_config_dao.SkuPage(m, offset, limit, ref total);
}
public void Push(dc_auto_return_goods_sku_search_dto input_data)
{
DB.dc_auto_return_goods_config_dao.BatchPush(input_data);
}
public void BatchApproval(batch_approval_input_dto input_data,UserData user)
{
DB.dc_auto_return_goods_config_dao.BatchApproval(input_data, user);
}
}
}
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoTurnOver.Common;
using AutoTurnOver.Models;
using AutoTurnOver.Utility;
using Microsoft.AspNetCore.Http;
......@@ -28,5 +29,46 @@ namespace AutoTurnOver.Controllers
total = total,
});
}
[HttpGet]
[BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【自动下单管理】->【退货汇总】->【推送】操作", 0)]
public JsonResult Push([FromQuery]dc_auto_return_goods_sku_search_dto search)
{
try
{
var service = new Services.ReturnGoodsConfigServices();
service.Push(search);
return new JsonResult(new { success = true });
}
catch (Exception ex)
{
return new JsonResult(new { success = false,message = ex.Message});
}
}
/// <summary>
/// 批量修改
/// </summary>
/// <returns></returns>
[HttpPost]
[BrowseLog("Bailun_aims", "触发【百伦自动周转系统】->【自动下单管理】->【退款汇总】->【批量审批】操作", 3)]
public JsonResult BatchApproval([FromBody]batch_approval_input_dto input_data )
{
try
{
var user = AutoUtility.GetUser();
if (user == null) return null;
new Services.ReturnGoodsConfigServices().BatchApproval(input_data, user);
return new JsonResult("");
}
catch (Exception ex)
{
return new JsonResult(ex.Message);
}
}
}
}
\ No newline at end of file
......@@ -48,5 +48,6 @@
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
}
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo"
}
......@@ -48,5 +48,6 @@
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
}
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo"
}
......@@ -48,5 +48,6 @@
"BrowseLogSetting": {
"Url": "http://saas.admin.bailuntec.com/Api/Ssoadmin/operationloginfo/addoperationloginfo",
"CanLog": "yes"
}
},
"SupplierReturnSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertReturnSkuInfo"
}
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