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

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

-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>
+93
View File
@@ -0,0 +1,93 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Store.Contracts.User.Entitys;
/// <summary>
/// OEM贴牌表
/// </summary>
[Table(Name = "wxxd.oem")]
public class OEMEntity
{
/// <summary>
/// id
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// oem_id
/// </summary>
[Column(Name = "oem_id")]
public string OemId { get; set; }
/// <summary>
/// 贴牌名称
/// </summary>
[Column(Name = "oem_name")]
public string OemName { get; set; }
/// <summary>
/// 贴牌管理人主账户
/// </summary>
[Column(Name = "oem_owner")]
public string OemOwner { get; set; }
/// <summary>
/// 图标
/// </summary>
[Column(Name = "oem_icon")]
public string OemIcon { get; set; }
/// <summary>
/// 题图
/// </summary>
[Column(Name = "oem_img")]
public string OemImg { get; set; }
/// <summary>
/// add_time
/// </summary>
[Column(Name = "add_time")]
public DateTime AddTime { get; set; }
/// <summary>
/// mdy_time
/// </summary>
[Column(Name = "mdy_time")]
public DateTime MdyTime { get; set; }
/// <summary>
/// is_del
/// </summary>
[Column(Name = "is_del")]
public byte IsDel { get; set; }
/// <summary>
/// 可提现余额,单位分
/// </summary>
[Column(Name = "available_balance")]
public long AvailableBalance { get; set; }
/// <summary>
/// 冻结余额,单位分
/// </summary>
[Column(Name = "frozen_balance")]
public long FrozenBalance { get; set; }
/// <summary>
/// 累计返利金额,单位分
/// </summary>
[Column(Name = "total_rebate_amount")]
public long TotalRebateAmount { get; set; }
/// <summary>
/// 累计提现金额,单位分
/// </summary>
[Column(Name = "total_withdraw_amount")]
public long TotalWithdrawAmount { get; set; }
}
+175
View File
@@ -0,0 +1,175 @@
using FreeSql.DataAnnotations;
using System;
namespace Store.Contracts.User.Entitys
{
/// <summary>
/// 用户表
/// </summary>
[Table(Name = "wxxd.user")]
public class UserEntity
{
/// <summary>
/// ID
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 用户昵称
/// </summary>
[Column(Name = "nick_name")]
public string NickName { get; set; }
/// <summary>
/// 用户名称(登录账户)
/// </summary>
[Column(Name = "user_name")]
public string UserName { get; set; }
/// <summary>
/// 登录密码
/// </summary>
[Column(Name = "password")]
public string Password { get; set; }
/// <summary>
/// card_id
/// </summary>
[Column(Name = "card_id")]
public string CardId { get; set; }
/// <summary>
/// 用户分组 3主号 4客服 5加盟 8登录 9采购 10加盟 11上货
/// </summary>
[Column(Name = "group_id")]
public byte GroupId { get; set; }
/// <summary>
/// 父账户用户名
/// </summary>
[Column(Name = "parent_user_name")]
public string ParentUserName { get; set; }
/// <summary>
/// oem编号,仅oem用户有值
/// </summary>
[Column(Name = "oem_id")]
public string OemId { get; set; }
/// <summary>
/// 手机号
/// </summary>
[Column(Name = "mobile")]
public string Mobile { get; set; }
/// <summary>
/// 添加时间
/// </summary>
[Column(Name = "add_time")]
public DateTime? AddTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[Column(Name = "mdy_time")]
public DateTime? MdyTime { get; set; }
/// <summary>
/// 公司名称
/// </summary>
[Column(Name = "company_name")]
public string CompanyName { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column(Name = "notes")]
public string Notes { get; set; }
/// <summary>
/// 超管等级 0 普通用户 1 超级管理员
/// </summary>
[Column(Name = "sa_level")]
public short? SaLevel { get; set; }
/// <summary>
/// 账户权限
/// </summary>
[Column(Name = "authority")]
public string Authority { get; set; }
/// <summary>
/// 子账号被禁止展示的功能页面
/// </summary>
[Column(Name = "forbidden_page")]
public string ForbiddenPage { get; set; }
/// <summary>
/// 账户积分,1积分=1元
/// </summary>
[Column(Name = "points")]
public decimal Points { get; set; }
/// <summary>
/// 积分历史累计充值金额
/// </summary>
[Column(Name = "recharge_points_total")]
public decimal? RechargePointsTotal { get; set; }
/// <summary>
/// 店铺每续费一个月需要的积分,单位元
/// </summary>
[Column(Name = "shop_points_per_month")]
public int ShopPointsPerMonth { get; set; }
/// <summary>
/// 可用余额
/// </summary>
[Column(Name = "balance")]
public decimal? Balance { get; set; }
/// <summary>
/// 累计充值金额
/// </summary>
[Column(Name = "recharge_amount_total")]
public decimal? RechargeAmountTotal { get; set; }
/// <summary>
/// 每单中转仓快递费用,单位元,两位小数
/// </summary>
[Column(Name = "postage_per_order")]
public decimal? PostagePerOrder { get; set; }
/// <summary>
/// 每单中转仓退货快递费用,单位元,两位小数
/// </summary>
[Column(Name = "refund_postage_per_order")]
public decimal? RefundPostagePerOrder { get; set; }
/// <summary>
/// 礼物每单额外收取费用,单位元,两位小数
/// </summary>
[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>
public bool IsMainUser
{
get => string.IsNullOrWhiteSpace(ParentUserName);
}
/// <summary>
/// 是否OEM租户
/// </summary>
public bool IsOEMTenant => !string.IsNullOrWhiteSpace(OemId);
}
}
@@ -0,0 +1,126 @@
using FreeSql.DataAnnotations;
using Store.Contracts.User.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Store.Contracts.User.Entitys;
[Table(Name = "wxxd.user_payment_record")]
public class UserPaymentRecordEntity
{
/// <summary>
/// id
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public long Id { get; set; }
/// <summary>
/// 变动类型,1:充值,2:采购花费,3:产品退款到账,4:运费退款到账,5:采购收款,6:产品退款扣除,7:运费退款扣除, 16:礼物单话费,20:中转仓扣费支出,23:中转仓退款收入
/// </summary>
[Column(Name = "type")]
public int Type { get; set; }
/// <summary>
/// 金额(元)
/// </summary>
[Column(Name = "amount")]
public decimal? Amount { get; set; }
/// <summary>
/// 归属oem用户的金额
/// </summary>
[Column(Name = "oem_amount")]
public decimal? OemAmount { get; set; }
/// <summary>
/// 余额(元)
/// </summary>
[Column(Name = "balance")]
public decimal? Balance { get; set; }
/// <summary>
/// 账户名
/// </summary>
[Column(Name = "user_name")]
public string UserName { get; set; }
/// <summary>
/// 平台编码
/// </summary>
[Column(Name = "platform_code")]
public string PlatformCode { get; set; }
/// <summary>
/// 订单id
/// </summary>
[Column(Name = "order_id")]
public string OrderId { get; set; }
/// <summary>
/// 售后单id
/// </summary>
[Column(Name = "after_sale_id")]
public long? AfterSaleId { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Column(Name = "create_by")]
public string CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column(Name = "create_time")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
[Column(Name = "update_by")]
public string UpdateBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[Column(Name = "update_time")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 是否已删除
/// </summary>
[Column(Name = "is_deleted")]
public int IsDeleted { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column(Name = "remark")]
public string Remark { get; set; }
/// <summary>
/// 扣款的对方账户名称
/// </summary>
[Column(Name = "counterparty_account_name")]
public string CounterpartyAccountName { get; set; }
/// <summary>
/// OEM是否结算 0未结算 1已结算
/// </summary>
[Column(Name = "settlement")]
public byte Settlement { get; set; } = 0;
/// <summary>
/// 退款流水号 外采&订单号
/// </summary>
[Column(Name = "refund_flow_no")]
public string RefundFlowNo { get; set; }
/// <summary>
/// 结算时间
/// </summary>
[Column(Name = "settlement_time")]
public DateTime? SettlementTime { get; set; }
}
@@ -0,0 +1,109 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Store.Contracts.User.Entitys
{
[Table(Name = "wxxd.user_points_record")]
public class UserPointsRecordEntity
{
/// <summary>
/// 主键(自增)
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public long Id { get; set; }
/// <summary>
/// 用户名(NOT NULL)
/// </summary>
[Column(Name = "user_name")]
public string UserName { get; set; }
/// <summary>
/// 用户昵称(NOT NULL)
/// </summary>
[Column(Name = "user_nick")]
public string UserNick { get; set; }
/// <summary>
/// 操作记录金额,单位元,最小1元(NOT NULL)
/// </summary>
[Column(Name = "delta_points")]
public decimal DeltaPoints { get; set; }
/// <summary>
/// 充值或消费后的当前金额(允许 NULL)
/// </summary>
[Column(Name = "new_points")]
public decimal? NewPoints { get; set; }
/// <summary>
/// 操作类型 消费 充值 转入 转出(NOT NULL)
/// </summary>
[Column(Name = "option_type")]
public string OptionType { get; set; }
/// <summary>
/// 操作者类型 管理员 用户(NOT NULL)
/// </summary>
[Column(Name = "operator_type")]
public string OperatorType { get; set; }
/// <summary>
/// 实际操作者用户名(NOT NULL)
/// </summary>
[Column(Name = "operator_name")]
public string OperatorName { get; set; }
/// <summary>
/// 消费店铺编号(消费才有值,充值为空,允许 NULL)
/// </summary>
[Column(Name = "shop_id")]
public string? ShopId { get; set; }
/// <summary>
/// 消费店铺名称(消费才有值,充值为空,允许 NULL)
/// </summary>
[Column(Name = "shop_account")]
public string? ShopAccount { get; set; }
/// <summary>
/// 备注(允许 NULL)
/// </summary>
[Column(Name = "remark")]
public string? Remark { get; set; }
/// <summary>
/// (点数转出时的)对方账户(允许 NULL)
/// </summary>
[Column(Name = "counterparty_account_name")]
public string? CounterpartyAccountName { get; set; }
/// <summary>
/// 支付宝订单的外部订单号(允许 NULL)
/// </summary>
[Column(Name = "out_trade_no")]
public string? OutTradeNo { get; set; }
/// <summary>
/// 添加时间(NOT NULL,默认 CURRENT_TIMESTAMP)
/// </summary>
[Column(Name = "add_time")]
public DateTime AddTime { get; set; }
/// <summary>
/// OEM是否结算 0未结算 1已结算
/// </summary>
[Column(Name = "settlement")]
public bool Settlement { get; set; }
/// <summary>
/// 结算时间
/// </summary>
[Column(Name = "settlement_time")]
public DateTime? SettlementTime { get; set; }
}
}
@@ -0,0 +1,43 @@
using FreeSql.DataAnnotations;
using System;
namespace Store.Contracts.User.Entitys
{
/// <summary>
/// 用户积分商店过期
/// </summary>
[Table(Name = "wxxd.user_points_shop_expire")]
public class UserPointsShopExpireEntity
{
/// <summary>
/// ID
/// </summary>
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 商店ID
/// </summary>
[Column(Name = "shop_id")]
public string ShopId { get; set; }
/// <summary>
/// 过期时间
/// </summary>
// 数据库列名末尾包含 U+200C,不能改成普通 expire_time。
[Column(Name = "expire_time\u200c")]
public int ExpireTime { get; set; }
/// <summary>
/// 添加时间
/// </summary>
[Column(Name = "add_time")]
public DateTime AddTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[Column(Name = "mdy_time")]
public DateTime MdyTime { get; set; }
}
}
@@ -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);
}