增加 同步物流服务,并扣款

This commit is contained in:
chfei committed 2026-09-23 16:22:34 +08:00
1 parent f27428b5f9
commit 6863194328
24 files changed
+538 -114

No files matched your search

+5 -1
View File
@@ -547,6 +547,7 @@ namespace KJD_Web.BLL.WXXD
postage_per_order = row.Table.Columns.Contains("postage_per_order") ? row["postage_per_order"].ParseToNullableDecimal() : null,
refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null,
gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null,
sync_logistics_per_order = row.Table.Columns.Contains("sync_logistics_per_order") ? row["sync_logistics_per_order"].ParseToNullableDecimal() : null,
};
var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : "";
var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : "";
@@ -765,6 +766,7 @@ namespace KJD_Web.BLL.WXXD
var postage_per_order = RegexUtils.GetStringQuery(ref inputData, "postage_per_order")?.Replace("'", "\\'");
var refund_postage_per_order = RegexUtils.GetStringQuery(ref inputData, "refund_postage_per_order")?.Replace("'", "\\'");
var gift_oem_amount_per_order = RegexUtils.GetStringQuery(ref inputData, "gift_oem_amount_per_order")?.Replace("'", "\\'");
var sync_logistics_per_order = RegexUtils.GetStringQuery(ref inputData, "sync_logistics_per_order")?.Replace("'", "\\'");
var oem_id = RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'");
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
@@ -803,6 +805,8 @@ namespace KJD_Web.BLL.WXXD
sql += " refund_postage_per_order=" + refund_postage_per_order + ",";
if (gift_oem_amount_per_order != null)
sql += " gift_oem_amount_per_order=" + gift_oem_amount_per_order + ",";
if (sync_logistics_per_order != null)
sql += " sync_logistics_per_order=" + sync_logistics_per_order + ",";
if (oem_id != null)
sql += " oem_id='" + oem_id + "',";
sql = sql.TrimEnd(',');
@@ -1641,7 +1645,7 @@ namespace KJD_Web.BLL.WXXD
remark = row["remark"].ParseToString(),
type = row["type"].ParseToInt(),
update_by = row["update_by"].ParseToString(),
update_time = row["update_time"].ParseToString().ParseToDateTime(),
update_time = row["update_time"].ParseToString().ParseToDateTime(),
oem_amount = row["oem_amount"].ParseToDecimal(),
refund_flow_no = row["oem_amount"].ParseToString(),
settlement = row["settlement"].ParseToNullableInt(),
-5
View File
@@ -215,17 +215,12 @@
<Compile Include="Controllers\UserController.cs" />
<Compile Include="Mappers\WeOrderMapper.cs" />
<Compile Include="Model\WxModel\oms_wei_ewaybill_path.cs" />
<Compile Include="Entitys\OEMEntity.cs" />
<Compile Include="Entitys\UserPaymentRecordEntity.cs" />
<Compile Include="Requests\RequestBase.cs" />
<Compile Include="Requests\Users\CUUserInfoRequest.cs" />
<Compile Include="Requests\Users\RebateRecordRequest.cs" />
<Compile Include="Responses\Users\RebateRecordResponse.cs" />
<Compile Include="Responses\Users\ShopRenewResponse.cs" />
<Compile Include="Entitys\ShopEntity.cs" />
<Compile Include="Entitys\UserEntity.cs" />
<Compile Include="Entitys\UserPointsRecordEntity.cs" />
<Compile Include="Entitys\UserPointsShopExpire.cs" />
<Compile Include="LogHelper.cs" />
<Compile Include="Model\ErpModel\ErpMerchantInfo.cs" />
<Compile Include="Model\JSTDownProdSkuInfo.cs" />
-1
View File
@@ -1,5 +1,4 @@
using AutoMapper;
using KJD_Web.Entitys;
using System;
using System.Collections.Generic;
using System.Linq;
+3 -1
View File
@@ -107,5 +107,7 @@ namespace KJD_Web.Model
/// 每一单礼物额外收取费用
/// </summary>
public decimal? gift_oem_amount_per_order { get; set; }
}
public decimal? sync_logistics_per_order { get; set; }
}
}
@@ -17,9 +17,6 @@ public class CUUserInfoRequest : SignRequestBase
/// <summary>昵称(URL 解码)</summary>
public string NickName { get; set; }
/// <summary>用户名(URL 解码)</summary>
public string UserName { get; set; }
/// <summary>手机号(URL 解码)</summary>
public string Mobile { get; set; }
@@ -58,6 +55,10 @@ public class CUUserInfoRequest : SignRequestBase
/// <summary>每单赠送 OEM 金额</summary>
public decimal? GiftOemAmountPerOrder { get; set; }
/// <summary>
/// 同步物流收费
/// </summary>
public decimal? SyncLogisticsPerOrder { get; set; }
/// <summary>OEM ID</summary>
public string OemId { get; set; }
@@ -1,7 +1,7 @@
using KJD_Web.Entitys;
using KJD_Web.Model.WxModel;
using KJD_Web.Model.WxModel;
using MySqlX.XDevAPI;
using Newtonsoft.Json;
using Store.Contracts.User.Entitys;
using System;
using System.Collections.Generic;
using System.Data.Common;
@@ -272,11 +272,11 @@ namespace KJD_Web.Services.Users
}
/// <summary>
/// 填充历史数据
/// </summary>
// /// <summary>
// /// 填充历史数据
// /// </summary>
// public void FillHistoryOemAmount()
// {
// List<UserPaymentRecordSmall> data = new List<UserPaymentRecordSmall>();
@@ -289,7 +289,7 @@ namespace KJD_Web.Services.Users
// {
// data = _freeSql.Select<UserPaymentRecordSmall>()
// .Where(a => a.type == 20 || a.type == 26)
// .Where(a => a.create_time > DateTime.Parse("2026-09-01 00:00:00"))
// .Where(a => a.create_time < DateTime.Parse("2026-09-01 00:00:00"))
// .OrderBy(a => a.id)
// .ToList();
// }
@@ -304,7 +304,9 @@ namespace KJD_Web.Services.Users
// {
// if (!string.IsNullOrEmpty(item.remark))
// {
// item.OrderId = item.remark.Split(':')[1];
// var ls = item.remark.Split(':');
// if (ls.Length != 2) continue;
// item.OrderId = ls[1];
// list.Add(item);
// if (list.Count == max)
// {
@@ -324,8 +326,8 @@ namespace KJD_Web.Services.Users
// list.ForEach(a => a.IsFill = true);
// File.WriteAllText(path, JsonConvert.SerializeObject(data));
// count += list.Count;
// list.Clear();
// Debug.WriteLine($"成功修改;{list.Count}");
// list.Clear();
// Debug.WriteLine($"共修改;{count}");
// }
@@ -399,38 +401,38 @@ namespace KJD_Web.Services.Users
// }
// return amount;
// }
//}
}
//[FreeSql.DataAnnotations.Table(Name = "wxxd.user_payment_record")]
//public class UserPaymentRecordSmall()
//{
// public long id { get; set; }
// public int type { get; set; }
// /// <summary>
// /// 金额(元)
// /// </summary>
// public decimal? amount { get; set; }
// /// <summary>
// /// 归属oem用户的金额
// /// </summary>
// public decimal? oem_amount { get; set; }
// public string remark { get; set; }
[FreeSql.DataAnnotations.Table(Name = "wxxd.user_payment_record")]
public class UserPaymentRecordSmall()
{
public long id { get; set; }
public int type { get; set; }
/// <summary>
/// 金额(元)
/// </summary>
public decimal? amount { get; set; }
/// <summary>
/// 归属oem用户的金额
/// </summary>
public decimal? oem_amount { get; set; }
public string remark { get; set; }
// public DateTime create_time { get; set; }
public DateTime create_time { get; set; }
// [FreeSql.DataAnnotations.Column(IsIgnore = true)]
// public bool IsFill { get; set; }
[FreeSql.DataAnnotations.Column(IsIgnore = true)]
public bool IsFill { get; set; }
// [FreeSql.DataAnnotations.Column(IsIgnore = true)]
// public string OrderId { get; set; }
//}
//[FreeSql.DataAnnotations.Table(Name = "erp.oms_wei_order")]
//public class weiOrder
//{
// public string order_id { get; set; }
// public string province_name { get; set; }
//}
[FreeSql.DataAnnotations.Column(IsIgnore = true)]
public string OrderId { get; set; }
}
[FreeSql.DataAnnotations.Table(Name = "erp.oms_wei_order")]
public class weiOrder
{
public string order_id { get; set; }
public string province_name { get; set; }
}
public class UserAmountSummary
@@ -1,8 +1,8 @@
using FreeSql.Internal.Model;
using KJD_Web.Entitys;
using KJD_Web.Requests.Users;
using KJD_Web.Responses.Users;
using MAX.Core.DependencyInjection;
using Store.Contracts.User.Entitys;
using System;
using System.Collections.Generic;
using System.Linq;
+82 -3
View File
@@ -1,21 +1,26 @@
using FreeSql;
using KJD_Web.Dtos.Users;
using KJD_Web.Entitys;
using KJD_Web.Model;
using KJD_Web.Model.ShopModel;
using KJD_Web.Requests.Users;
using KJD_Web.Utils;
using MAX.Core.DependencyInjection;
using MAX.Core.Logger;
using NaiBa.Util.Extension;
using Store.Contracts.Order.Entitys;
using Store.Contracts.User.Entitys;
using Store.Contracts.User.Enums;
using Store.Contracts.User.Interfaces;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using Ubiety.Dns.Core;
using YourNamespace;
namespace KJD_Web.Services.Users
{
public partial class UserService : ITransientDependency
public partial class UserService : IUserService, ITransientDependency
{
/// <summary>
/// 商铺续费每月30
@@ -27,10 +32,12 @@ namespace KJD_Web.Services.Users
private const int MaxRenewDuration = 120;
private readonly IFreeSql _freeSql;
private readonly ILoggerFacade _logger;
public UserService(IFreeSql freeSql)
public UserService(IFreeSql freeSql, ILoggerFacade logger)
{
_freeSql = freeSql ?? throw new ArgumentNullException(nameof(freeSql));
_logger = logger;
}
public bool IsOem(string userName)
@@ -326,6 +333,8 @@ namespace KJD_Web.Services.Users
if (userinfo.GiftOemAmountPerOrder.HasValue)
update = update.Set(a => a.GiftOemAmountPerOrder, userinfo.GiftOemAmountPerOrder.Value);
if (userinfo.SyncLogisticsPerOrder.HasValue)
update = update.Set(a => a.SyncLogisticsPerOrder, userinfo.SyncLogisticsPerOrder.Value);
//主账户允许修改OEM
if (oldUser.IsMainUser)
{
@@ -365,5 +374,75 @@ namespace KJD_Web.Services.Users
work.Commit();
}
/// <summary>
/// 用户消费付款记录
/// </summary>
/// <param name="userName"></param>
/// <param name="orderId"></param>
/// <param name="type"></param>
/// <param name="tarn"></param>
/// <exception cref="Exception"></exception>
public void UserPayment(string userName, string orderId, UserPaymentTypes type, DbTransaction tarn = null)
{
using var work = tarn != null ? _freeSql.CreateUnitOfWork(tarn) : _freeSql.CreateUnitOfWork();
var trFreeSql = work.Orm;
var user = trFreeSql.Select<UserEntity>()
.Where(a => a.UserName == userName)
.First();
if (user == null)
{
throw new Exception("用户不存在");
}
if (user.IsMainUser == false)
{
var mainUser = _freeSql.Select<UserEntity>()
.Where(a => a.UserName == user.ParentUserName)
.First();
if (mainUser == null)
{
throw new Exception("错误的账户");
}
user.SyncLogisticsPerOrder = mainUser.SyncLogisticsPerOrder;
}
if (type != UserPaymentTypes.同步单号) throw new Exception("不支持的类型");
var payItem = new UserPaymentRecordEntity
{
Type = (int)type,
Amount = (user.SyncLogisticsPerOrder ?? 0.0m) + 1.7m,
UserName = user.UserName,
PlatformCode = "WEISHOP",
OrderId = orderId,
CreateBy = user.UserName,
CreateTime = DateTime.Now,
Remark = "同步物流:",
CounterpartyAccountName = user.UserName,
};
if (user.IsOEMTenant)
{
payItem.OemAmount = user.SyncLogisticsPerOrder;
}
payItem.Balance = user.Balance - payItem.Amount;
var affrows = trFreeSql.Insert<UserPaymentRecordEntity>(payItem).ExecuteAffrows();
if (affrows != 1)
{
_logger.Error($"付款失败:{userName},{orderId},{type}");
throw new Exception("付款失败");
}
affrows = trFreeSql.Update<UserEntity>()
.Set(a => a.Balance - payItem.Amount)
.Where(a => a.UserName == user.UserName)
.Where(a => a.Balance >= payItem.Amount)
.ExecuteAffrows();
if (affrows != 1)
{
_logger.Error($"付款失败,余额不足:{userName},{orderId},{type}");
throw new Exception("余额不足");
}
work.Commit();
}
}
}
-6
View File
@@ -1,6 +0,0 @@
namespace Store.Contracts;
public class Class1
{
}
+255
View File
@@ -0,0 +1,255 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Contracts.Shops;
/// <summary>
/// 店铺表
/// </summary>
[Table(Name = "erp.o_shop")]
public class ShopEntity
{
/// <summary>
/// 主键
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public long Id { get; set; }
/// <summary>
/// 店铺名
/// </summary>
[Column(Name = "name")]
public string Name { get; set; }
/// <summary>
/// 对应第三方平台Id
/// </summary>
[Column(Name = "type")]
public int Type { get; set; }
/// <summary>
/// 登录获取的Cookie信息
/// </summary>
[Column(Name = "login_cookie")]
public string LoginCookie { get; set; }
/// <summary>
/// 访问需要的header参数
/// </summary>
[Column(Name = "header_params")]
public string HeaderParams { get; set; }
/// <summary>
/// 店铺url
/// </summary>
[Column(Name = "url")]
public string Url { get; set; }
/// <summary>
/// 排序
/// </summary>
[Column(Name = "sort")]
public int Sort { get; set; }
/// <summary>
/// 状态(1正常2已删除)
/// </summary>
[Column(Name = "status")]
public int? Status { get; set; }
/// <summary>
/// 描述
/// </summary>
[Column(Name = "remark")]
public string Remark { get; set; }
/// <summary>
/// 第三方平台店铺id,淘宝天猫开放平台使用
/// </summary>
[Column(Name = "seller_id")]
public long? SellerId { get; set; }
/// <summary>
/// 授权时间
/// </summary>
[Column(Name = "auth_time")]
public long? AuthTime { get; set; }
/// <summary>
/// 服务市场授权到期时间
/// </summary>
[Column(Name = "expire_time")]
public long? ExpireTime { get; set; }
/// <summary>
/// Appkey
/// </summary>
[Column(Name = "app_key")]
public string AppKey { get; set; }
/// <summary>
/// Appsercet
/// </summary>
[Column(Name = "app_secret")]
public string AppSecret { get; set; }
/// <summary>
/// 小红椒的access_token
/// </summary>
[Column(Name = "access_token_xhj")]
public string AccessTokenXhj { get; set; }
/// <summary>
/// 第三方平台sessionKey(access_token)
/// </summary>
[Column(Name = "access_token")]
public string AccessToken { get; set; }
/// <summary>
/// 小红椒多久到期
/// </summary>
[Column(Name = "expires_in_xhj")]
public long? ExpiresInXhj { get; set; }
/// <summary>
/// 到期
/// </summary>
[Column(Name = "expires_in")]
public long? ExpiresIn { get; set; }
/// <summary>
/// 小红椒access_token开始时间
/// </summary>
[Column(Name = "access_token_begin_xhj")]
public long? AccessTokenBeginXhj { get; set; }
/// <summary>
/// access_token开始时间
/// </summary>
[Column(Name = "access_token_begin")]
public long? AccessTokenBegin { get; set; }
/// <summary>
/// 刷新token
/// </summary>
[Column(Name = "refresh_token")]
public string RefreshToken { get; set; }
/// <summary>
/// 刷新token过期时间
/// </summary>
[Column(Name = "refresh_token_timeout")]
public long? RefreshTokenTimeout { get; set; }
/// <summary>
/// 代理api请求凭证
/// </summary>
[Column(Name = "session")]
public string Session { get; set; }
/// <summary>
/// 代理api获取请求凭证的shopkey字段
/// </summary>
[Column(Name = "shop_key")]
public string ShopKey { get; set; }
/// <summary>
/// 请求url
/// </summary>
[Column(Name = "api_request_url")]
public string ApiRequestUrl { get; set; }
/// <summary>
/// 回掉URL
/// </summary>
[Column(Name = "api_callback_url")]
public string ApiCallbackUrl { get; set; }
/// <summary>
/// 负责人id
/// </summary>
[Column(Name = "manage_user_id")]
public long? ManageUserId { get; set; }
/// <summary>
/// 默认运费模板id,抖店上传商品使用
/// </summary>
[Column(Name = "default_freight_template_id")]
public long? DefaultFreightTemplateId { get; set; }
/// <summary>
/// 默认品牌id,抖店上传商品使用
/// </summary>
[Column(Name = "default_brand_id")]
public long? DefaultBrandId { get; set; }
/// <summary>
/// 店铺是否已开启尺码自动优化,0:不需要开启,1:未开启,2:已开启
/// </summary>
[Column(Name = "auto_size_template_optimize")]
public byte? AutoSizeTemplateOptimize { get; set; }
/// <summary>
/// 店铺分组
/// </summary>
[Column(Name = "shop_group_id")]
public long? ShopGroupId { get; set; }
/// <summary>
/// 企业账号用户id
/// </summary>
[Column(Name = "corporate_account_user_id")]
public long? CorporateAccountUserId { get; set; }
/// <summary>
/// 国家/地区
/// </summary>
[Column(Name = "region_id")]
public long? RegionId { get; set; }
/// <summary>
/// 商户ID
/// </summary>
[Column(Name = "merchant_id")]
public long? MerchantId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column(Name = "create_time")]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Column(Name = "create_by")]
public string CreateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Column(Name = "update_time")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[Column(Name = "update_by")]
public string UpdateBy { get; set; }
/// <summary>
/// api调用状态0未开启1已开启
/// </summary>
[Column(Name = "api_status")]
public int ApiStatus { get; set; }
/// <summary>
/// 是否开启自动购买外采礼物单,0:未开启,1:已开启
/// </summary>
[Column(Name = "auto_purchase_external_gift")]
public int? AutoPurchaseExternalGift { get; set; }
}
-4
View File
@@ -9,8 +9,4 @@
<ProjectReference Include="..\Store.Framework\Store.Framework.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="User\" />
</ItemGroup>
</Project>
@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.Entitys;
namespace Store.Contracts.User.Entitys;
/// <summary>
@@ -1,7 +1,7 @@
using FreeSql.DataAnnotations;
using System;
namespace KJD_Web.Entitys
namespace Store.Contracts.User.Entitys
{
/// <summary>
/// 用户表
@@ -153,6 +153,13 @@ namespace KJD_Web.Entitys
[Column(Name = "gift_oem_amount_per_order")]
public decimal? GiftOemAmountPerOrder { get; set; }
/// <summary>
/// 同步物流费用,单位元,两位小数
/// </summary>
[Column(Name = "sync_logistics_per_order")]
public decimal? SyncLogisticsPerOrder { get; set; }
/// <summary>
/// 是否主账户
/// </summary>
@@ -160,5 +167,9 @@ namespace KJD_Web.Entitys
{
get => string.IsNullOrWhiteSpace(ParentUserName);
}
/// <summary>
/// 是否OEM租户
/// </summary>
public bool IsOEMTenant => !string.IsNullOrWhiteSpace(OemId);
}
}
@@ -1,10 +1,11 @@
using FreeSql.DataAnnotations;
using Store.Contracts.User.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.Entitys;
namespace Store.Contracts.User.Entitys;
[Table(Name = "wxxd.user_payment_record")]
public class UserPaymentRecordEntity
@@ -61,7 +62,7 @@ public class UserPaymentRecordEntity
/// 售后单id
/// </summary>
[Column(Name = "after_sale_id")]
public long AfterSaleId { get; set; }
public long? AfterSaleId { get; set; }
/// <summary>
/// 创建人
@@ -91,7 +92,7 @@ public class UserPaymentRecordEntity
/// 是否已删除
/// </summary>
[Column(Name = "is_deleted")]
public int? IsDeleted { get; set; }
public int IsDeleted { get; set; }
/// <summary>
/// 备注
@@ -109,7 +110,7 @@ public class UserPaymentRecordEntity
/// OEM是否结算 0未结算 1已结算
/// </summary>
[Column(Name = "settlement")]
public byte? Settlement { get; set; }
public byte Settlement { get; set; } = 0;
/// <summary>
/// 退款流水号 外采&订单号
@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace KJD_Web.Entitys
namespace Store.Contracts.User.Entitys
{
[Table(Name = "wxxd.user_points_record")]
@@ -1,7 +1,7 @@
using FreeSql.DataAnnotations;
using System;
namespace KJD_Web.Entitys
namespace Store.Contracts.User.Entitys
{
/// <summary>
/// 用户积分商店过期
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Contracts.User.Enums;
/// <summary>
/// 用户付款类型
/// </summary>
public enum UserPaymentTypes
{
充值 = 1,
//采购花费 = 2,
//产品退款到账 = 3,
//运费退款到账 = 4,
//采购收款 = 5,
//产品退款扣除 = 6,
//运费退款扣除 = 7,
礼物单支出 = 16,
中转仓扣费支出 = 20,
中转仓作废返还收入 = 23,
中转仓超重支出 = 24,
退货包裹扣费支出 = 26,
中转仓快递超重费用 = 28,
支付宝在线充值 = 30,
云仓退货支出 = 31,
礼物单退费 = 34,
同步单号 = 55,
}
@@ -0,0 +1,32 @@
using Store.Contracts.User.Entitys;
using Store.Contracts.User.Enums;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.Contracts.User.Interfaces;
public interface IUserService
{
OEMEntity GetOEMByOemId(string oemId, bool isCache = true);
OEMEntity GetOEMByUserName(string userName, bool isCache = true);
List<UserEntity> GetOEMUsers(string oemId, bool includeSu = true);
List<UserEntity> GetUserAndSubUser(string userName);
UserEntity GetUserByUserName(string userName);
bool IsOem(string userName);
OEMEntity SettleOemFlows(string userName, DbTransaction tarn = null);
long SettleUserFlows(string userName, DbTransaction tarn = null);
/// <summary>
/// 用户消费付款记录
/// </summary>
/// <param name="userName"></param>
/// <param name="orderId"></param>
/// <param name="type"></param>
/// <param name="tarn"></param>
/// <exception cref="Exception"></exception>
void UserPayment(string userName, string orderId, UserPaymentTypes type, DbTransaction tarn = null);
}
@@ -177,7 +177,7 @@ public class VirtualLogisticsApi : ISingletonDependency
}
item.Encoding = Encoding.UTF8;
item.ProxyIp = "127.0.0.1:8080";
//item.ProxyIp = "127.0.0.1:8080";
long unix = DateHelper.GetCurrentUnixTimestampInSeconds();
@@ -1,5 +1,6 @@
using Store.Framework.Base;
using Store.Framework.Models;
using Store.SyncLogistics.Dtos;
using Store.VirtualLogistics.Apis;
using Store.VirtualLogistics.Entitys;
using Store.VirtualLogistics.Models;
@@ -99,11 +100,13 @@ public class LogisticsController : ApiControllerBase
/// 购买快递
/// </summary>
[HttpPost]
public IHttpActionResult Buy(string orderId)
public IHttpActionResult Buy(BuyLogisticsRequest request)
{
try
{
var result = _logisticsService.Buy(orderId, "");
string orderId = request.OrderId;
string agentOrderId = request.AgentOrderId;
var result = _logisticsService.Buy(request.UserName, orderId, agentOrderId);
return Ok(ApiResult.Success(result));
}
catch (Exception ex)
@@ -0,0 +1,14 @@
using Store.Framework.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Store.SyncLogistics.Dtos;
public class BuyLogisticsRequest : SignRequestBase
{
public string OrderId { get; set; }
public string AgentOrderId { get; set; }
}
+1 -1
View File
@@ -261,7 +261,7 @@ public class EncryptDatas
/// 订单商品数量,视频号必填
/// </summary>
[JsonProperty("sku_cnt")]
public string SkuCnt { get; set; }
public int SkuCnt { get; set; }
}
public class ExtendParams
{
@@ -2,6 +2,9 @@ using MAX.Core.Commons;
using MAX.Core.DependencyInjection;
using MAX.Core.Logger;
using Store.Contracts.Order.Entitys;
using Store.Contracts.Shops;
using Store.Contracts.User.Entitys;
using Store.Contracts.User.Interfaces;
using Store.VirtualLogistics.Apis;
using Store.VirtualLogistics.Entitys;
using Store.VirtualLogistics.Models;
@@ -16,14 +19,20 @@ namespace Store.VirtualLogistics.Services;
public class VirtualLogisticsService : ITransientDependency
{
/// <summary>
/// 固定费用1.7元
/// </summary>
const decimal FIXEDFEES = 1.7m;
private IFreeSql _freeSql;
private readonly ILoggerFacade _logger;
private readonly IUserService _userService;
private readonly VirtualLogisticsApi _api;
public VirtualLogisticsService(VirtualLogisticsApi api, IFreeSql freeSql, ILoggerFacade logger)
public VirtualLogisticsService(VirtualLogisticsApi api, IFreeSql freeSql, ILoggerFacade logger, IUserService userService)
{
_freeSql = freeSql ?? throw new ArgumentNullException(nameof(freeSql));
_logger = logger;
_userService = userService;
_api = api;
}
@@ -64,15 +73,22 @@ public class VirtualLogisticsService : ITransientDependency
/// <summary>
/// 购买快递
/// </summary>
public List<YhSyncLogisticsEntity> Buy(string orderId, string ds_orderId)
public List<YhSyncLogisticsEntity> Buy(string userName, string orderId, string agentOrderId)
{
var item = _freeSql.Select<OrderPddBuyerOrderEntity>()
if (string.IsNullOrEmpty(orderId) || string.IsNullOrWhiteSpace(agentOrderId))
{
throw new ArgumentNullException(nameof(orderId));
}
var user = _userService.GetUserByUserName(userName);
if (user == null) throw new Exception("错误的账号");
//中间订单
var middleOrder = _freeSql.Select<OrderPddBuyerOrderEntity>()
.Where(a => a.OrderSn == orderId)
.First();
if (item == null) throw new Exception("错误的订单号");
if (middleOrder == null) throw new Exception("错误的订单号");
//middleOrder.TrackingNumber = "YT0709726946568";
var w_order = _freeSql.Select<WeiOrderEntity>()
.Where(a => a.OrderId == item.WxOrderId)
.Where(a => a.OrderId == middleOrder.WxOrderId)
.First();
if (w_order == null) throw new Exception("错误的订单号");
@@ -81,6 +97,12 @@ public class VirtualLogisticsService : ITransientDependency
.First();
if (productItem == null) throw new Exception("错误的订单详情号");
var shop = _freeSql.Select<ShopEntity>()
.Where(a => a.Id == productItem.ShopId)
.First();
if (shop == null) throw new Exception("错误的店铺");
BuyRequest request = new BuyRequest()
{
KuaidiId = "874",
@@ -98,20 +120,28 @@ public class VirtualLogisticsService : ITransientDependency
new RecItem
{
OrderSn = orderId,
ShopOrder =w_order.OrderId,
RecName = w_order.UserName,
RecMobile = w_order.TelNumber,
RecProvince = w_order.ProvinceName,
RecCity = w_order.CityName,
RecDistrict = w_order.CountyName,
RecAddress = w_order.DetailInfo,
EwaybillOrderCode="wx7809625286c28f2f",
EncryptDatas=new EncryptDatas
{
DsOrderId=ds_orderId,
DsOrderId=agentOrderId,
SkuId = productItem.SkuId,
ProductId = productItem.ProductId,
SkuCnt = productItem.SkuCnt.ToString(),
SkuCnt = productItem.SkuCnt,
FromShopCode = shop.AppKey,
},
OtherKuaidiSn= "6738192431"//item.TrackingNumber,
ExtendParams=new ExtendParams{
Token="",
Api="",
DsOrderId =agentOrderId
},
OtherKuaidiSn= middleOrder.TrackingNumber,
}
]
@@ -141,6 +171,9 @@ public class VirtualLogisticsService : ITransientDependency
_logger.Error("购买同步单提交到数据库错误");
throw new Exception("记录同步单失败");
}
//todo 更新UserBlance
_userService.UserPayment(user.UserName, orderId, type: Contracts.User.Enums.UserPaymentTypes.同步单号);
return yhSyncs;
}
+5 -32
View File
@@ -84,7 +84,7 @@ internal class GiftLogisticsTest
{
try
{
var ret = logisticsApi.QueryOrderStatus(["260705-168736857712823"]);
var ret = logisticsApi.QueryOrderStatus(["260923-405295603341688"]);
Console.WriteLine(string.Join(" ", ret.Data.Select(a => $"{a.OrderSn}:{a.KuaidiSn}({a.Status})")));
}
catch (Exception ex)
@@ -95,41 +95,14 @@ internal class GiftLogisticsTest
[Test]
public void BuyTest()
{
//var request = new BuyRequest
//{
// KuaidiId = "874",
// GoodsId = "8473",
// CangId = "914",
// Platform = 6,
// Auth = 1,
// SendName = "张三",
// SendMobile = "18255185853",
// SendProvince = "辽宁省",
// SendCity = "大连市",
// SendDistrict = "甘井子区",
// SendAddress = "革镇堡幸福家园2栋",
// RecList = new List<RecItem>
// {
// new RecItem
// {
// OrderSn = "3739252814971847936",
// RecName = "李四",
// RecMobile = "18255185853",
// RecProvince = "湖南省",
// RecCity = "衡阳市",
// RecDistrict = "雁峰区",
// RecAddress = "和谐小区 1栋",
// OtherKuaidiSn="315097997688420"
// }
// }
//};
//var ret = logisticsApi.Buy(request);
var userService = _container.Resolve<VirtualLogisticsService>();
var ret = userService.Buy("260705-168736857712823", "4439341152678214144");
var logisticsService = _container.Resolve<VirtualLogisticsService>();
var ret = logisticsService.Buy("260923-573109716621688", "4439363558732480512", "15222220006");
if (ret != null)
{
Console.WriteLine(string.Join(" ", ret.Select(a => $"{a.OrderId}:{a.TrackingNumber}")));
}
//var userService = _container.Resolve<UserService>();
//userService.UserPayment("15222220006", "260923-405295603341688", type: Store.Contracts.User.Enums.UserPaymentTypes.同步单号);
}
[Test]
public void UploadPickupTest()