[关闭]
@Wahson 2021-03-02T09:30:55.000000Z 字数 16993 阅读 470

在线商城


零、开发计划

开发时间(按照8h/天,前后端各投入1.25人/天计算):
84h / (8 + 2) = 8.4d
114h / (8 + 2) = 11.4d
联调:5d
测试:10d
此处输入图片的描述

一、订单域 33h

添加购物车 4h

  1. 检查添加的商品是否已存在购物车
  2. 如果不存在,则新增购物车记录
  3. 如果已存在,则累加数量

查询购物车 1h

修改购物车数量 1h

  1. 修改数量、更新金额字段

删除购物车 1h

  1. 把选中的购物车商品添加到购物车历史表
  2. 删除原购物车中的商品

购物车下单 6h

  1. 删除购物车()
  2. 新建order记录
  3. 按照商户分组生成seller_order,以及order_item
  4. 调用微信支付接口,发起支付,获取prepay_id
  5. 返回prepay_id

订单支付 6h

  1. 调用微信支付接口,发起支付,获取prepay_id,并返回

支付结果通知 4h

  1. 微信支付完成,微信通知回调
  2. 根据返回结果,记录wx_transaction_idpaid_at

订单发货 6h

  1. if(在线下单) 调用微信物流助手下单
  2. 新建配送单
  3. 更新订单状态

运单轨迹更新通知 4h

  1. 更新delivery.action

二、商品域

商品管理

原子方法 22h
  1. 新增商品 8h
  1. 新建spu
  2. 新建sku
  3. 新建spu_attachment
  4. 新建sku_attachment

主图显示规则:

spu可上传多张主图
sku可上传一张主图
商品列表默认显示spu第一张主图
选择规格页面,默认显示spu第一张主图,选择规格后显示为sku主图(若有)

销售属性保存规则:
// todo

  1. 修改商品 4h
  1. 更新商品信息
  2. 如果有新添加规格,新建sku
  3. 商品状态改为待上架
  1. 上架审核 1h
  1. 商品状态改为已上架
  2. 记录上架时间
  1. 下架 1h
  1. 商品状态改为已下架
  2. 记录下架时间
商品查询
  1. 查询商品列表 1h
  2. 查询商品详情 6h
  3. 查询商户商品列表 1h

三、CRM域

商户管理

原子方法 17h
  1. 新增商户 3h
  2. 商户修改基本信息 3h
  3. 商户审核 1h
  4. 商户上传证件 2h
  5. 新增地址 2h
  6. 修改地址 2h
  7. 删除地址 1h
商户查询
  1. 查询商户列表 1h
  2. 查询商户信息 2h

四、基础设施

接口幂等校验

分布式锁

商品缓存

id 生成规则

  1. sku id 规则: sku最大流水号 << 16 | 16位时间戳
  2. spu id :
  3. order id : orderId最大流水号 << 32 | 32位用户id
  4. seller_order_id: seller_order_id 最大流水号 << 32 | 32位商户id
  5. merchant id: 32位商户id
  6. 用户id: 32位用户id

领域划分

mall_order、mall_product、mall_crm

服务框架搭建 12h

五、客户端:小程序 32h

六、运营系统 34h

七、商家端运营后台 48h

前端技术栈

  1. UI参考 https://shop.weixin.qq.com/

八、数据模型

  1. create database mall_crm_db;
  2. create database mall_order_db;
  3. create database mall_product_db;
  4. create table mall_crm_db.merchant
  5. (
  6. id bigint unsigned not null default '0',
  7. merchant_name varchar(128) not null default '' comment '商户名称',
  8. merchant_diminutive varchar(32) not null default '' comment '商户简称',
  9. legal_person varchar(32) not null default '' comment '法人',
  10. address varchar(256) not null default '' comment '商户地址',
  11. phone varchar(32) not null default '' comment '联系方式',
  12. customer_hotline varchar(32) not null default '' comment '客服热线',
  13. status tinyint(2) unsigned not null default '0' comment '状态,1:待认账(to_be_authenticate);20:已认证(authenticated)',
  14. uniform_social_credit_code varchar(50) not null default '' comment '统一社会信用代码',
  15. profit_share_rate decimal(4, 3) not null default 0 comment '平台分账比例',
  16. created_at datetime not null default '0000-00-00 00:00:00',
  17. updated_at datetime not null default '0000-00-00 00:00:00',
  18. primary key (id)
  19. ) engine = innoDB charset = utf8mb4 comment '商户表';
  20. create table mall_crm_db.merchant_license
  21. (
  22. merchant_id bigint unsigned not null default 0 comment '商户id',
  23. license_type tinyint unsigned not null default '0' comment '证件类型,1:统一社会信用代码证(uniform_social_credit);',
  24. license_code varchar(64) not null default '' comment '证件编码',
  25. license_begin_date date not null default '0000-00-00' comment '证书有效期开始',
  26. license_end_date date not null default '0000-00-00' comment '证书有效期结束',
  27. created_at datetime not null default '0000-00-00 00:00:00',
  28. updated_at datetime not null default '0000-00-00 00:00:00',
  29. primary key (merchant_id, license_type)
  30. ) engine = innoDB charset = utf8mb4 comment '商户证件信息';
  31. create table mall_crm_db.merchant_address(
  32. id bigint unsigned not null default '0',
  33. merchant_id bigint unsigned not null default '0',
  34. type tinyint(2) unsigned not null default 1 comment '地址类型,1:快递发货地址;2:退货地址',
  35. name varchar(100) CHARACTER SET utf8 not null default '' COMMENT '联系人姓名',
  36. tel varchar(20) CHARACTER SET utf8 NOT NULL default '' COMMENT '联系电话',
  37. addr varchar(255) CHARACTER SET utf8 NOT NULL default '' COMMENT '地址',
  38. post_code varchar(6) CHARACTER SET utf8 NOT NULL default '' COMMENT '邮政编码',
  39. is_default tinyint(2) unsigned not null default 0 comment '是否默认地址',
  40. remark varchar(255) not null default '' comment '备注',
  41. is_deleted tinyint(2) unsigned not null default 0 comment '是否已删除',
  42. created_at datetime not null default '0000-00-00 00:00:00',
  43. updated_at datetime not null default '0000-00-00 00:00:00',
  44. primary key (id)
  45. ) engine = innoDB charset = utf8mb4 comment '商户地址信息';
  46. create table mall_product_db.spu(
  47. id bigint unsigned not null default '0',
  48. -- category_id int unsigned not null default '0',
  49. merchant_id bigint unsigned not null default '0' comment '商户id',
  50. hash bigint unsigned not null default '0',
  51. title varchar(128) not null default '商品标题',
  52. subtitle varchar(64) not null default '商品子标题',
  53. promotion_desc varchar(128) not null default '促销信息',
  54. stock_reduce_strategy tinyint(3) unsigned NOT NULL COMMENT '库存扣减方式 1-拍下减库存 2-付款减库存',
  55. # -- 价格含义
  56. # price decimal(8,2) unsigned not null default '销售价',
  57. # refer_price decimal(8,2) unsigned not null default '参考价',
  58. sale_attr varchar(256) not null default '' comment '销售属性',
  59. # key_attr varchar(256) not null default '关键属性',
  60. # category_attr varchar(1024) not null default '分类属性',
  61. # property bigint unsigned not null default '0',
  62. status tinyint(2) unsigned not null default 10 comment '商品状态:10:待上架;20:已上架;90:已下架',
  63. on_shelved_at timestamp default null comment '上架时间',
  64. off_shelved_at timestamp default null comment '下架时间',
  65. -- 售罄:当sku中库存都为0
  66. is_sold_out tinyint(3) unsigned NOT NULL default 0 COMMENT '是否售罄 0-在售 1-已售罄',
  67. is_deleted tinyint(3) unsigned NOT NULL default 0 COMMENT '是否删除 0-未删除 1-删除',
  68. keyword varchar(128) not null default '搜索关键字',
  69. created_at datetime not null default '0000-00-00 00:00:00',
  70. updated_at datetime not null default '0000-00-00 00:00:00',
  71. primary key (id)
  72. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 comment 'SPU=standard product unit(标准产品)';
  73. # create table mall_product_db.spu_detail(
  74. # spu_id int unsigned not null default '0',
  75. # merchant_id int unsigned not null default '0' comment '商户id',
  76. # spu_detail_type tinyint unsigned not null default '0',
  77. # -- 图片
  78. # spu_detail text not null default '' comment '商品详情',
  79. # created_at datetime not null default '0000-00-00 00:00:00',
  80. # updated_at datetime not null default '0000-00-00 00:00:00',
  81. # primary key (spu_id, spu_detail_type)
  82. # ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 comment '存储SPU详情类型,及其详情描述(html)';
  83. -- 详情图
  84. create table mall_product_db.spu_attachment
  85. (
  86. id bigint unsigned not null auto_increment,
  87. spu_id bigint unsigned not null default '0',
  88. type tinyint(2) unsigned not null default 1 comment '类型,1:主图(head_img);2:详情图(detail_img)',
  89. url varchar(255) not null default '' comment '图片地址',
  90. seq tinyint(3) unsigned not null default 1 comment '序列号',
  91. created_at datetime not null default '0000-00-00 00:00:00',
  92. updated_at datetime not null default '0000-00-00 00:00:00',
  93. primary key (id),
  94. unique key uk_spu_seq (spu_id, seq)
  95. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 comment 'spu附件';
  96. create table mall_product_db.sku(
  97. id bigint unsigned not null default '0',
  98. merchant_id bigint unsigned not null default '0' comment '商户id',
  99. spu_id bigint unsigned not null default '0',
  100. title varchar(128) not null default '' comment '标题',
  101. subtitle varchar(64) not null default '' comment '副标题',
  102. -- 存储格式
  103. sale_attr varchar(255) not null default '' comment '销售属性', -- key1:value1;key2:value2;
  104. sale_attr_key varchar(255) not null default '' comment '销售属性描述', -- value1-value2
  105. sale_price decimal(8,2) unsigned not null default 0.00 comment '销售价',
  106. category_attr varchar(1024) not null default '' comment '分类属性',
  107. customize_attr varchar(256) not null default '' comment '自定义属性',
  108. keyword varchar(128) not null default '' comment '关键字',
  109. snap_version smallint unsigned not null default '1' comment '快照版本',
  110. is_deleted tinyint(3) unsigned NOT NULL default 0 COMMENT '是否删除 0-未删除 1-删除',
  111. created_at datetime not null default '0000-00-00 00:00:00' comment '创建时间',
  112. updated_at datetime not null default '0000-00-00 00:00:00' comment '最后更新时间',
  113. primary key (id),
  114. key idx_spu (spu_id),
  115. key idx_updated_at (updated_at)
  116. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sku';;
  117. create table mall_product_db.sku_attachment
  118. (
  119. id bigint unsigned not null auto_increment,
  120. sku_id bigint unsigned not null default '0',
  121. type tinyint(2) unsigned not null default 1 comment '类型,1:主图(head_img)',
  122. url varchar(255) not null default '' comment '图片地址',
  123. seq tinyint(3) unsigned not null default 1 comment '序列号',
  124. created_at datetime not null default '0000-00-00 00:00:00',
  125. updated_at datetime not null default '0000-00-00 00:00:00',
  126. primary key (id),
  127. unique key uk_spu_seq (sku_id, seq)
  128. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 comment 'sku附件';
  129. CREATE TABLE mall_order_db.shopping_cart_item (
  130. id bigint(20) unsigned NOT NULL COMMENT '主键',
  131. wx_user_id bigint(20) unsigned NOT NULL COMMENT '微信用户',
  132. merchant_id bigint unsigned not null default '0' comment '商户id',
  133. spu_id bigint(20) unsigned NOT NULL COMMENT '商品SPU_ID',
  134. sku_id bigint(20) unsigned NOT NULL COMMENT '商品ID',
  135. sku_name varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称',
  136. sku_spec varchar(50) NOT NULL DEFAULT '' COMMENT '商品规格名称',
  137. quantity smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT '商品数量',
  138. price decimal(8, 2) not null default 0.00 comment '加入购物车的价格',
  139. source tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '操作来源 1-首页 2-商品列表 3-商品详情 4-活动页面',
  140. created_at datetime not null default '0000-00-00 00:00:00' comment 'SKU详情的首次添加时间',
  141. updated_at datetime not null default '0000-00-00 00:00:00' comment 'SKU详情的最近一次修改时间',
  142. PRIMARY KEY (`id`),
  143. KEY `idx_customer_id` (`wx_user_id`) USING HASH COMMENT 'customer'
  144. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='购物车';
  145. -- 购物车下单或删除时,记录到历史表,原表进行物理删除
  146. CREATE TABLE mall_order_db.shopping_cart_item_his (
  147. id bigint(20) unsigned NOT NULL COMMENT '主键',
  148. wx_user_id bigint(20) unsigned NOT NULL COMMENT '微信用户',
  149. merchant_id bigint unsigned not null default '0' comment '商户id',
  150. spu_id bigint(20) unsigned NOT NULL COMMENT '商品SPU_ID',
  151. sku_id bigint(20) unsigned NOT NULL COMMENT '商品ID',
  152. sku_name varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称',
  153. sku_spec varchar(50) NOT NULL DEFAULT '' COMMENT '商品规格名称',
  154. quantity smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT '商品数量',
  155. price decimal(8, 2) not null default 0.00 comment '加入购物车的价格',
  156. source tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '操作来源 1-首页 2-商品列表 3-商品详情 4-活动页面',
  157. sci_created_at datetime not null default '0000-00-00 00:00:00' comment '加购物车的时间',
  158. created_at datetime not null default current_time comment '加入历史表的时间',
  159. PRIMARY KEY (`id`),
  160. KEY `idx_customer_id` (`wx_user_id`) USING HASH COMMENT 'customer'
  161. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='购物车历史表,用以记录用户删除或成交的购物车记录,可用来进行数据分析';
  162. CREATE TABLE mall_order_db.`order` (
  163. id bigint unsigned NOT NULL default 0 COMMENT '订单号',
  164. status tinyint(2) not null comment '订单状态,1:待付款;2:待发货;3:待收货;4:交易成功;6:交易关闭',
  165. wx_user_id bigint not null default 0 comment '微信用户id',
  166. # pay_id bigint unsigned default null comment '支付记录id',
  167. paid_at datetime DEFAULT NULL COMMENT '支付完成时间',
  168. total_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '优惠前总价',
  169. shipping_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '邮费',
  170. pay_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '支付总价',
  171. adjust_fee decimal(8,2) not null default 0.00 comment '调价后总价',
  172. discount_fee decimal(8,2) not null default 0.00 comment '折扣金额',
  173. created_at datetime not null default '0000-00-00 00:00:00',
  174. updated_at datetime not null default '0000-00-00 00:00:00',
  175. PRIMARY KEY (id),
  176. key idx_wx_user(wx_user_id)
  177. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单,记录用户一次下单行为';
  178. --
  179. -- order 根据 商户拆单
  180. create table mall_order_db.seller_order(
  181. --
  182. id bigint unsigned not null default 0 comment '商户订单号',
  183. wx_user_id bigint not null default 0 comment '微信用户id',
  184. merchant_id bigint unsigned not null default '0' comment '商户id',
  185. --
  186. order_id bigint unsigned not null default 0 comment '订单id',
  187. status tinyint(2) not null comment '订单状态,1:待付款;2:待发货;3:待收货;4:交易成功;5:售后中;6:交易关闭',
  188. # pay_id bigint unsigned default null comment '支付记录id',
  189. should_paid_before datetime NOT NULL default '0000-00-00 00:00:00' COMMENT '最晚支付时间,超过订单自动取消',
  190. wx_transaction_id varchar(32) default null comment '微信支付系统生成的订单号,支付通知中返回',
  191. paid_at datetime DEFAULT NULL COMMENT '支付完成时间',
  192. profit_sharing_status tinyint(2) unsigned not null default 10 comment '冗余分账状态,10:分账中;20:分账成功;90:分账失败',
  193. finished_at datetime DEFAULT NULL COMMENT '交易完成时间,交易成功/交易关闭时间',
  194. # 费用
  195. total_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '总价 = 货物总价 + 邮费',
  196. item_total_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '货物总价',
  197. shipping_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '邮费',
  198. pay_fee decimal(8,2) not null DEFAULT 0.00 COMMENT '支付总价',
  199. adjust_fee decimal(8,2) not null default 0.00 comment '调价后总价',
  200. discount_fee decimal(8,2) not null default 0.00 comment '折扣金额',
  201. # 收货信息
  202. recv_name varchar(100) CHARACTER SET utf8 not null default '' COMMENT '收货人',
  203. recv_tel varchar(20) CHARACTER SET utf8 NOT NULL default '' COMMENT '收货电话',
  204. recv_addr varchar(255) CHARACTER SET utf8 NOT NULL default '' COMMENT '收货地址',
  205. recv_post_code varchar(6) CHARACTER SET utf8 NOT NULL default '' COMMENT '邮政编码',
  206. recv_province varchar(10) CHARACTER SET utf8 NOT NULL default '' comment '省',
  207. recv_city varchar(10)CHARACTER SET utf8 NOT NULL default '' comment '市',
  208. recv_area varchar(10) CHARACTER SET utf8 NOT NULL default '' comment '区/县',
  209. # 发票信息
  210. # is_need_invoice tinyint(2) unsigned not null default '0' comment '是否需要发票',
  211. # invoice_title varchar(128) not null default '' comment '发票抬头',
  212. # invoice_tax_no varchar(128) not null default '' comment '公司税号,发票抬头为公司时,需提供',
  213. # invoice_content varchar(256) not null default '' comment '发票内容',
  214. # 退货信息
  215. # refund_type varchar(255) DEFAULT NULL,
  216. # refund_fee double DEFAULT NULL,
  217. # refund_state varchar(255) DEFAULT NULL,
  218. # refund_id varchar(255) DEFAULT NULL,
  219. buyer_remark varchar(255) not null default '' comment '买家备注',
  220. seller_remark varchar(255) not null default '' comment '卖家备注',
  221. created_at datetime not null default '0000-00-00 00:00:00',
  222. updated_at datetime not null default '0000-00-00 00:00:00',
  223. PRIMARY KEY (id),
  224. key idx_merchant_id(merchant_id),
  225. key idx_user_id(wx_user_id),
  226. key idx_order_id(order_id),
  227. unique key uk_transaction_id(wx_transaction_id) using BTREE,
  228. unique key uk_order_id_merchant_id(order_id, merchant_id)
  229. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='卖家维度订单,按merchant维度拆分后的order';
  230. create table mall_order_db.order_item(
  231. id bigint unsigned not null default 0 comment 'id',
  232. merchant_id bigint unsigned not null default '0' comment '商户id',
  233. order_id bigint unsigned not null default 0 comment '主单id',
  234. seller_order_id bigint unsigned not null default 0 comment '商户订单号',
  235. spu_id bigint(20) unsigned NOT NULL COMMENT '商品SPU_ID',
  236. sku_id bigint(20) unsigned NOT NULL COMMENT '商品ID',
  237. sku_name varchar(100) NOT NULL DEFAULT '' COMMENT '商品名称',
  238. sku_spec varchar(50) NOT NULL DEFAULT '' COMMENT '商品规格名称',
  239. quantity smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT '商品数量',
  240. origin_price decimal(8, 2) unsigned not null default 0.00 comment '商品原价',
  241. total_fee decimal(8,2) unsigned not null DEFAULT 0.00 COMMENT '商品总价',
  242. pay_fee decimal(8,2) unsigned not null DEFAULT 0.00 COMMENT '支付总价 = total_fee + shipping_fee',
  243. # adjust_fee decimal(8,2) unsigned not null default 0.00 comment '改价',
  244. # discount_fee decimal(8,2) unsigned not null default 0.00 comment '折扣金额',
  245. created_at datetime not null default '0000-00-00 00:00:00',
  246. updated_at datetime not null default '0000-00-00 00:00:00',
  247. PRIMARY KEY (id),
  248. key idx_order_id(order_id),
  249. key idx_seller_order_id(seller_order_id)
  250. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单详情';
  251. create table mall_crm_db.express_account(
  252. id bigint unsigned not null default 0 comment 'id',
  253. merchant_id bigint unsigned not null default '0' comment '商户id',
  254. biz_id varchar(64) not null default '' comment '快递公司客户编码',
  255. biz_secret varchar(64) not null default '' comment '快递公司客户密钥',
  256. express_company_id varchar(32) not null default '' comment '微信返回快递公司ID',
  257. express_company_name varchar(64) not null default '' comment '微信返回快递公司名称',
  258. created_at datetime not null default '0000-00-00 00:00:00',
  259. updated_at datetime not null default '0000-00-00 00:00:00',
  260. PRIMARY KEY (id),
  261. unique key uk_merchant_id_delivery_id(merchant_id, express_company_id),
  262. unique key uk_delivery_id_biz_id(express_company_id, biz_id)
  263. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='快递账号,用以绑定微信物流助手';
  264. -- 一个订单对应一个物流单
  265. create table mall_order_db.delivery(
  266. id bigint unsigned not null default 0 comment 'id',
  267. merchant_id bigint unsigned not null default '0' comment '商户id',
  268. order_id bigint unsigned not null default 0 comment '订单号',
  269. seller_order_id bigint unsigned not null default 0 comment '商户订单号,对应商户分账单号out_order_no',
  270. status tinyint(2) unsigned not null default 10 comment '配送状态',
  271. waybill_id varchar(64) not null default '' comment '运单号',
  272. express_company_id varchar(32) not null default '' comment '快递公司ID',
  273. express_company_name varchar(64) not null default '' comment '快递公司名称',
  274. action varchar(2048) not null default '' comment '物流轨迹',
  275. confirm_recv_at datetime default null comment '确认收货时间',
  276. created_at datetime not null default '0000-00-00 00:00:00',
  277. updated_at datetime not null default '0000-00-00 00:00:00',
  278. PRIMARY KEY (id),
  279. unique key uk_seller_order_id(seller_order_id)
  280. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配送单';
  281. -- seller_order交易完成后,自动发起分账抽佣
  282. -- 发起分账时,写入记录,分账申请成功返回后,记录分账单号
  283. -- 定时查询分账结果,更新分账状态。分账失败后需要重试机制
  284. create table mall_order_db.profit_sharing(
  285. id bigint unsigned not null default 0 comment 'id',
  286. -- 相同wx_transaction_id的分账记录状态应一致,要么到分账成功,要么都失败,不存在部分成功的情况
  287. status tinyint(2) unsigned not null default 10 comment '分账状态,10:分账中;20:分账成功;90:分账失败',
  288. merchant_id bigint unsigned not null default '0' comment '商户id',
  289. order_id bigint unsigned not null default 0 comment '订单号',
  290. seller_order_id bigint unsigned not null default 0 comment '商户订单号,对应商户分账单号out_order_no',
  291. wx_transaction_id varchar(32) not null default '' comment '微信支付系统生成的订单号,支付通知中返回',
  292. wx_order_id varchar(64) not null default '' comment '微信分账单号,微信系统返回的唯一标识,分账申请成功时返回',
  293. -- order_id 分组累加后的金额应等于`order`应付金额
  294. -- wx_transaction_id 分组累加后的金额应等于`seller_order`应付金额
  295. -- merchant_id 分组累加后的金额应等于对应商家入账的金额,服务商户可能会在一个订单中有多次分账
  296. amount decimal(10, 2) unsigned not null default 0.00 comment '分账金额',
  297. paid_at datetime not NULL default '0000-00-00 00:00:00' COMMENT '支付完成时间',
  298. profit_shared_at datetime not NULL default '0000-00-00 00:00:00' COMMENT '分账完成时间',
  299. created_at datetime not null default '0000-00-00 00:00:00',
  300. updated_at datetime not null default '0000-00-00 00:00:00',
  301. PRIMARY KEY (id),
  302. unique key uk_merchant_transaction_id(merchant_id, wx_transaction_id)
  303. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='微信支付分账记录,平台与商户分账';
  304. -- 分账失败记录表,便于重试,重试成功后,删除失败记录,更新分账主表状态
  305. create table mall_order_db.profit_sharing_fail(
  306. id bigint unsigned not null default 0 comment 'id',
  307. profit_sharing_id bigint unsigned not null default 0,
  308. order_id bigint unsigned not null default 0 comment '订单号',
  309. seller_order_id bigint unsigned not null default 0 comment '商户订单号,对应商户分账单号out_order_no',
  310. wx_transaction_id varchar(32) not null default '' comment '微信支付系统生成的订单号,支付通知中返回',
  311. wx_order_id varchar(64) not null default '' comment '微信分账单号,微信系统返回的唯一标识,分账申请成功时返回',
  312. is_deleted tinyint(2) unsigned not null default 0 comment '是否已删除',
  313. fail_reason varchar(255) not null default '' comment '失败原因',
  314. retry_times tinyint(2) unsigned not null default 0 comment '重试次数',
  315. created_at datetime not null default '0000-00-00 00:00:00',
  316. updated_at datetime not null default '0000-00-00 00:00:00',
  317. PRIMARY KEY (id),
  318. unique key uk_wx_transaction_id(wx_transaction_id)
  319. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分账失败记录';
  320. -- 订单(order,delivery,cart)
  321. -- 商品(sku,spu)
  322. -- crm(merchant)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注