20260706_redesign.sql 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. -- ouyang 2026-7-17 10:11:34
  2. ALTER TABLE xhHd
  3. add COLUMN `homeRule` tinyint(4) NOT NULL DEFAULT '0' COMMENT '上门遵循规则 0遵循总设置 1遵循自定义' after `updateTime`;
  4. ALTER TABLE xhCustom
  5. add COLUMN `homeRule` tinyint(4) NOT NULL DEFAULT '0' COMMENT '上门遵循规则 0遵循总设置 1遵循自定义' after `updateTime`;
  6. -- ouyang 2026-7-17 11:31:52 用户地址列表
  7. CREATE TABLE `xhUserAddress` (
  8. `id` bigint(11) NOT NULL AUTO_INCREMENT,
  9. `userId` int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  10. `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收货人',
  11. `phone` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '手机号',
  12. `lat` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '纬度',
  13. `long` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '经度',
  14. `province` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '省',
  15. `city` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '市',
  16. `dist` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '区县',
  17. `address` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '街道地址',
  18. `floor` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '楼号门牌号',
  19. `fullAddress` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '完整地址',
  20. `showAddress` varchar(900) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '地图接口显示的完整地址',
  21. `default` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否默认地址',
  22. `tag` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '标签',
  23. `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间',
  24. `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  25. PRIMARY KEY (`id`) USING BTREE,
  26. KEY `idx_userId` (`userId`) USING BTREE
  27. ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户地址列表';
  28. -- ouyang 2026-7-20 15:27:39
  29. CREATE TABLE `xhPsExplain` (
  30. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  31. `methodId` int(11) NOT NULL COMMENT '关联 PsMethod.id',
  32. `explain` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '说明文字,最多50字',
  33. `color` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '颜色:1黑 2红 3蓝',
  34. `fontWeight` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '字重:1常规 2加粗',
  35. `sort` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '显示顺序,越小越靠前',
  36. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  37. PRIMARY KEY (`id`),
  38. KEY `idx_method_sort` (`methodId`,`sort`)
  39. ) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='花店配送方式说明条目';
  40. CREATE TABLE `xhPsMethod` (
  41. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  42. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  43. `mainId` int(11) NOT NULL DEFAULT '0' COMMENT 'mainId',
  44. `style` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'sendType 0送货 1自取 2跑腿 3物流 4快递 transType 0德邦 1顺丰 2冷链 3航空 4送货 5自取',
  45. `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '名称',
  46. `originName` char(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '原名',
  47. `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态:1启用 0禁用',
  48. `sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '显示顺序',
  49. `minAmount` decimal(10,2) DEFAULT '0.00' COMMENT '最低消费金额,0表示没有要求',
  50. `minNum` smallint(5) DEFAULT '0' COMMENT '最低消费数量,0表示没有要求',
  51. `unMeet` tinyint(3) unsigned DEFAULT '0' COMMENT '不满条件,0收运费 1收包装费 2不能下单',
  52. `unMeetFee` decimal(10,2) DEFAULT '0.00' COMMENT '运费(送货) / 包装费(快递)',
  53. `startKm` decimal(8,2) DEFAULT '0.00' COMMENT '起步公里数',
  54. `startPrice` decimal(10,2) DEFAULT '0.00' COMMENT '起步公里内价格(元)',
  55. `perKmPrice` decimal(10,2) DEFAULT '0.00' COMMENT '超出起步每公里加价(元)',
  56. `changeRate` decimal(6,2) DEFAULT '0.00' COMMENT '临时涨价百分比,负数为降价',
  57. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  58. `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  59. PRIMARY KEY (`id`),
  60. UNIQUE KEY `uk_main_type` (`mainId`,`style`)
  61. ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='花店送货方式配置表';
  62. CREATE TABLE `xhPsReduceRule` (
  63. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  64. `methodId` int(11) NOT NULL COMMENT '关联 PsMethod.id',
  65. `meetNum` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '满数量',
  66. `meetAmount` decimal(10,2) NOT NULL COMMENT '满金额',
  67. `freeKm` decimal(8,2) NOT NULL COMMENT 'X公里内免配送费',
  68. `sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '规则排序,越小越靠前',
  69. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  70. PRIMARY KEY (`id`),
  71. KEY `idx_method_sort` (`methodId`,`sort`)
  72. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='花店送货方式,跑腿,花材,满减规则';
  73. -- ouyang 2026-7-22 17:13:06
  74. -- =============================================================================
  75. -- 分销功能 — 数据库建表脚本(hdApp)
  76. -- =============================================================================
  77. SET NAMES utf8mb4;
  78. SET SESSION lock_wait_timeout = 10;
  79. -- -----------------------------------------------------------------------------
  80. -- 1. 分销用户表(id = xhCustom.id,非自增)
  81. -- -----------------------------------------------------------------------------
  82. CREATE TABLE IF NOT EXISTS `xhDistributionUser` (
  83. `id` bigint(20) unsigned NOT NULL COMMENT '主键,与 xhCustom.id 一致',
  84. `customId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '客户ID, xhCustom id',
  85. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  86. `inviterId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '邀请人 xhCustom.id,0无',
  87. `inviteTime` datetime DEFAULT NULL COMMENT '邀请时间',
  88. `inviteCount` int(11) NOT NULL DEFAULT '0' COMMENT '拉新数量',
  89. `orderCount` int(11) NOT NULL DEFAULT '0' COMMENT '本人获佣订单数',
  90. `orderAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '本人获佣订单金额(计佣基数合计)',
  91. `pendingCommission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '待结算提成(已付款未分佣)',
  92. `settledCommission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '已结算提成(已分佣)',
  93. `totalCommission` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计提成(待结算+已结算)',
  94. `totalDeposit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '累计存入金额',
  95. `availDeposit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '可存入分红余额(已结算未存入)',
  96. `upOrderCount` int(11) NOT NULL DEFAULT '0' COMMENT '为上级贡献订单数(本人下单产生)',
  97. `upOrderAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '为上级贡献订单金额(计佣基数合计)',
  98. `upCommissionAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '为上级贡献提成金额';
  99. `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1正常 0禁用',
  100. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  101. `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  102. PRIMARY KEY (`id`),
  103. KEY `idx_shop` (`shopId`),
  104. KEY `idx_inviter` (`shopId`, `inviterId`),
  105. KEY `idx_customId` (`customId`)
  106. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分销用户统计表';
  107. -- -----------------------------------------------------------------------------
  108. -- 1.1 客户与分销员绑定(按时间递减计佣必填;inviteTime 是邀请成为分销员,bindTime 是客户绑定关系)
  109. -- -----------------------------------------------------------------------------
  110. CREATE TABLE IF NOT EXISTS `xhDistributionCustomerBind` (
  111. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  112. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  113. `hdId` int(11) NOT NULL DEFAULT '0' COMMENT '花店ID',
  114. `buyerId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '下单客户 xhCustom.id',
  115. `distId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '绑定分销员 xhCustom.id',
  116. `bindTime` datetime NOT NULL COMMENT '绑定时间(递减计佣起点)',
  117. `bindSource` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1邀请 2扫码 3首单 4后台',
  118. `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1有效 0失效',
  119. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  120. `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  121. PRIMARY KEY (`id`),
  122. UNIQUE KEY `uk_shop_buyer` (`shopId`, `buyerId`),
  123. KEY `idx_dist` (`shopId`, `distId`, `bindTime`),
  124. KEY `idx_buyer` (`buyerId`)
  125. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户与分销员绑定';
  126. -- -----------------------------------------------------------------------------
  127. -- 2. 分销规则(图2 固定比例 / 图3 按时间递减)
  128. -- -----------------------------------------------------------------------------
  129. CREATE TABLE IF NOT EXISTS `xhDistributionRule` (
  130. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  131. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  132. `mainId` int(11) NOT NULL DEFAULT '0' COMMENT 'mainId',
  133. `status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '分销功能 0关 1开',
  134. `settleDays` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '订单完成后 N 天结算',
  135. `bonusType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1固定比例 2按时间递减',
  136. `bonusRate` decimal(6,2) NOT NULL DEFAULT '0.00' COMMENT '固定比例%(bonusType=1)',
  137. `durationType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '分红时长 1不限 2限制',
  138. `durationDays` int(11) NOT NULL DEFAULT '0' COMMENT '限制天数(durationType=2)',
  139. `timeStartType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '计时起点 1绑定时间',
  140. `productScope` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1全部 2指定商品 3指定分类',
  141. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  142. `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  143. PRIMARY KEY (`id`),
  144. UNIQUE KEY `uk_shop` (`shopId`),
  145. KEY `idx_mainId` (`mainId`)
  146. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分销规则';
  147. -- -----------------------------------------------------------------------------
  148. -- 2.1 时间递减阶梯
  149. -- -----------------------------------------------------------------------------
  150. CREATE TABLE IF NOT EXISTS `xhDistributionRuleTier` (
  151. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  152. `ruleId` int(11) NOT NULL DEFAULT '0' COMMENT 'xhDistributionRule.id',
  153. `minDays` int(11) NOT NULL DEFAULT '0' COMMENT '起始天数(含)',
  154. `maxDays` int(11) NOT NULL DEFAULT '0' COMMENT '结束天数(含);0=及以上',
  155. `bonusRate` decimal(6,2) NOT NULL DEFAULT '0.00' COMMENT '佣金比例%',
  156. `sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
  157. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  158. PRIMARY KEY (`id`),
  159. KEY `idx_rule_sort` (`ruleId`, `sort`)
  160. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分销规则阶梯';
  161. -- -----------------------------------------------------------------------------
  162. -- 2.2 指定商品/分类(productScope=2/3 时使用,若仅做「全部商品」可暂不建)
  163. -- -----------------------------------------------------------------------------
  164. CREATE TABLE IF NOT EXISTS `xhDistributionRuleScope` (
  165. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  166. `ruleId` int(11) NOT NULL DEFAULT '0' COMMENT 'xhDistributionRule.id',
  167. `scopeType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1商品 2分类',
  168. `targetId` int(11) NOT NULL DEFAULT '0' COMMENT 'goodsId 或 categoryId',
  169. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  170. PRIMARY KEY (`id`),
  171. UNIQUE KEY `uk_rule_target` (`ruleId`, `scopeType`, `targetId`),
  172. KEY `idx_rule` (`ruleId`)
  173. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分销规则商品范围';
  174. -- -----------------------------------------------------------------------------
  175. -- 3. 订单分销记录(图4/5)
  176. -- -----------------------------------------------------------------------------
  177. CREATE TABLE IF NOT EXISTS `xhDistributionOrder` (
  178. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  179. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  180. `hdId` int(11) NOT NULL DEFAULT '0' COMMENT '花店ID',
  181. `orderId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID',
  182. `orderSn` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
  183. `buyerId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '下单客户 xhCustom.id',
  184. `buyerName` varchar(80) NOT NULL DEFAULT '' COMMENT '下单客户名(快照)',
  185. `distId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '获佣分销员 xhCustom.id',
  186. `distName` varchar(80) NOT NULL DEFAULT '' COMMENT '获佣人名(快照)',
  187. `orderAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单商品金额',
  188. `payAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '实付(含运费)',
  189. `sendCost` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '运费',
  190. `commissionBase` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '计佣基数=实付-运费',
  191. `commissionRate` decimal(6,2) NOT NULL DEFAULT '0.00' COMMENT '佣金比例%(快照)',
  192. `commissionAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '佣金金额',
  193. `bonusType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1固定 2递减(快照)',
  194. `bindTime` datetime DEFAULT NULL COMMENT '绑定时间(快照)',
  195. `bindDays` int(11) NOT NULL DEFAULT '0' COMMENT '下单距绑定天数(快照)',
  196. `settleStatus` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '0待结算 1已结算 2已失效',
  197. `orderTime` datetime DEFAULT NULL COMMENT '下单时间',
  198. `payTime` datetime DEFAULT NULL COMMENT '付款时间',
  199. `finishTime` datetime DEFAULT NULL COMMENT '订单完成时间',
  200. `settleTime` datetime DEFAULT NULL COMMENT '分佣时间',
  201. `invalidTime` datetime DEFAULT NULL COMMENT '失效时间',
  202. `invalidReason` varchar(255) NOT NULL DEFAULT '' COMMENT '失效原因',
  203. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  204. `updateTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  205. PRIMARY KEY (`id`),
  206. UNIQUE KEY `uk_order_dist` (`orderId`, `distId`),
  207. KEY `idx_shop_settle` (`shopId`, `settleStatus`, `orderTime`),
  208. KEY `idx_dist_settle` (`distId`, `settleStatus`, `settleTime`),
  209. KEY `idx_orderSn` (`orderSn`),
  210. KEY `idx_buyer` (`buyerId`)
  211. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单分销记录';
  212. -- -----------------------------------------------------------------------------
  213. -- 4. 分销流水(图6)
  214. -- -----------------------------------------------------------------------------
  215. CREATE TABLE IF NOT EXISTS `xhDistributionFlow` (
  216. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  217. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  218. `hdId` int(11) NOT NULL DEFAULT '0' COMMENT '花店ID',
  219. `xhCustomId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '分销员 xhCustom.id',
  220. `flowType` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1订单分红 2分红存入 3退款扣回',
  221. `amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '变动金额;分红+ 存入/扣回-',
  222. `availAfter` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '变动后可存分红余额',
  223. `refType` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '1分销订单 2存入日志',
  224. `refId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '关联业务ID',
  225. `refSn` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号/存入编号',
  226. `buyerName` varchar(80) NOT NULL DEFAULT '' COMMENT '下单客户(flowType=1)',
  227. `flowStatus` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1待结算 2已结算 3存入成功 4已扣回',
  228. `flowTime` datetime NOT NULL COMMENT '业务时间',
  229. `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  230. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  231. PRIMARY KEY (`id`),
  232. KEY `idx_custom_time` (`xhCustomId`, `flowTime`),
  233. KEY `idx_shop_type_time` (`shopId`, `flowType`, `flowTime`),
  234. KEY `idx_ref` (`refType`, `refId`)
  235. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分销流水';
  236. -- -----------------------------------------------------------------------------
  237. -- 5. 分红存入日志(图7)
  238. -- -----------------------------------------------------------------------------
  239. CREATE TABLE IF NOT EXISTS `xhDistributionDepositLog` (
  240. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  241. `shopId` int(11) NOT NULL DEFAULT '0' COMMENT '门店ID',
  242. `hdId` int(11) NOT NULL DEFAULT '0' COMMENT '花店ID',
  243. `xhCustomId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '客户 xhCustom.id',
  244. `depositSn` varchar(32) NOT NULL DEFAULT '' COMMENT '存入编号',
  245. `depositAmount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '存入金额',
  246. `beforeAvail` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '存入前可存分红',
  247. `afterAvail` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '存入后可存分红',
  248. `balanceChangeId` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'xhCustomBalanceChange.id',
  249. `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  250. `addTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '存入时间',
  251. PRIMARY KEY (`id`),
  252. UNIQUE KEY `uk_depositSn` (`depositSn`),
  253. KEY `idx_custom_time` (`xhCustomId`, `addTime`),
  254. KEY `idx_shop_time` (`shopId`, `addTime`)
  255. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='分红存入日志';
  256. -- =============================================================================
  257. -- 分销功能脚本结束
  258. -- =============================================================================
  259. -- 新增订单完成时间 ouyang 2026-7-24 18:18:01
  260. ALTER TABLE `xhOrder`
  261. ADD COLUMN `successTime` datetime NULL DEFAULT '0000-00-00 00:00:00' COMMENT '订单完成时间' AFTER `settleTime`;
  262. -- # 分销延迟结算定时任务 ouyang 2026-7-24 18:27:52
  263. -- 0 * * * * cd /path/to/huahuibao && php yii distribution/settle-due --limit=100