[关闭]
@Wahson 2021-02-06T22:08:01.000000Z 字数 15116 阅读 408

技术--工作周报(2021-02-06)

周报 Wanbo周报

上周回顾

  • 运营系统优化已上线
    • 仓库录入,地址回车换行符处理
    • 付款原因增加运费 payment_application
    • listOrder, 公司名匹配时,处理掉半角字符
    • 我发起的OA,增加撤销审批权限,增加类型筛选
    • OA审批优化
    • 历史牌号数据处理
    • 定金逾期统计
    • 单据明细增加报销费用字段
    • 修改交易员
    • staff表增加员工收款账号
  • 一期功能整理及数据模型整理中,已完成90%

下周计划

  • 运营系统优化 梁荣生 陈均活
    • 增加物流商管理,物流商增删改查
  • 在线商城
    • 一期功能整理 梁华生
    • 数据模型设计 梁华生
    • 商城小程序UI继续完善 陈均活
  1. create table delivery_db.logistics_company(
  2. id bigint unsigned not null default 0 auto_increment comment 'id',
  3. name varchar(64) not null default '' comment '物流商名称',
  4. tax_rate decimal(5, 3) unsigned not null default 1.00 comment '税率',
  5. is_deleted tinyint(2) unsigned not null default 0 comment '是否删除',
  6. created_at datetime not null default '0000-00-00 00:00:00',
  7. created_by int unsigned not null default 0,
  8. updated_at datetime not null default '0000-00-00 00:00:00',
  9. updated_by int unsigned not null default 0,
  10. PRIMARY KEY (id)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='物流商';

在线商城数据模型

此处输入图片的描述

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