diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index 0d47f9372..3dbcf3d59 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -121,6 +121,13 @@ public class WxCouponController extends BaseController { EnumCouponType.COUPON_PREORDER.getCode()}; wxCoupon.setTypes(Arrays.asList(typeArray)); + + Integer[] sendTypeArray = { + EnumCouponSendType.ACTIVE.getCode(), + EnumCouponSendType.PASSIVE.getCode(),}; + + wxCoupon.setSendTypes(Arrays.asList(sendTypeArray)); + if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ String coryColumn = "c."+wxCoupon.getSortColumns(); wxCoupon.setSortColumns(coryColumn); diff --git a/mallinkAdmin/src/main/resources/db/migration/V2021101200001__order.sql b/mallinkAdmin/src/main/resources/db/migration/V2021101200001__order.sql new file mode 100644 index 000000000..5d673f4e7 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2021101200001__order.sql @@ -0,0 +1,201 @@ +ALTER TABLE wx_order_0 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_1 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_2 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_3 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_4 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_5 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_6 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_7 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_8 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_9 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_10 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_11 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_12 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_13 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_14 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_15 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_16 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_17 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_18 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_19 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_20 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_21 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_22 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_23 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_24 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_25 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_26 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_27 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_28 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_29 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_30 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_31 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_32 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_33 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_34 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_35 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_36 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_37 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_38 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_39 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_40 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_41 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_42 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_43 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_44 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_45 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_46 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_47 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_48 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_49 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_50 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_51 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_52 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_53 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_54 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_55 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_56 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_57 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_58 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_59 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_60 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_61 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_62 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_63 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_64 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_65 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_66 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_67 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_68 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_69 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_70 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_71 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_72 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_73 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_74 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_75 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_76 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_77 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_78 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_79 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_80 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_81 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_82 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_83 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_84 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_85 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_86 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_87 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_88 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_89 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_90 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_91 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_92 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_93 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_94 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_95 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_96 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_97 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_98 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_order_99 ADD COLUMN `parent_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; + +ALTER TABLE wx_coupon_order_0 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_1 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_2 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_3 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_4 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_5 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_6 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_7 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_8 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_9 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_10 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_11 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_12 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_13 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_14 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_15 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_16 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_17 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_18 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_19 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_20 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_21 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_22 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_23 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_24 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_25 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_26 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_27 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_28 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_29 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_30 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_31 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_32 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_33 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_34 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_35 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_36 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_37 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_38 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_39 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_40 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_41 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_42 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_43 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_44 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_45 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_46 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_47 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_48 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_49 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_50 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_51 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_52 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_53 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_54 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_55 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_56 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_57 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_58 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_59 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_60 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_61 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_62 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_63 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_64 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_65 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_66 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_67 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_68 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_69 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_70 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_71 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_72 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_73 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_74 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_75 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_76 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_77 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_78 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_79 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_80 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_81 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_82 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_83 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_84 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_85 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_86 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_87 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_88 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_89 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_90 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_91 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_92 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_93 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_94 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_95 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_96 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_97 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_98 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; +ALTER TABLE wx_coupon_order_99 ADD COLUMN `parent_coupon_order_id` bigint(20) not null default 0 COMMENT '父订单编号'; diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java index 12a8e6e6b..a0d9641fe 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -338,7 +338,7 @@ public class WxCouponOrderController extends BaseController { WxCouponOrder couponOrder = null; try { wxCouponOrder.setVerifyRemark(verifyRemark); - couponOrder = wxCouponOrderService.verify(wxCouponOrder, wxMerchantBUser); + couponOrder = wxCouponOrderService.verify(wxCouponOrder, wxMerchantBUser, EnumCouponVerifyType.VERIFY_B); } catch (MallinkException e) { logger.error("核销异常: " + e.getMessage()); return new ResultData(e.getErrorCode(), e.getMessage()); diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java index e61bea376..796c1bf60 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -80,7 +80,14 @@ public class WxCouponController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); } - String key = "cc:" + couponChannelId; + String key = "cc:"; + if(couponChannelIdL > 0){ + key = key + couponChannelIdL; + }else if(couponIdL > 0){ + key = key + couponIdL; + }else{ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId/couponId为空"); + } ValueOperations operations = cdRedisTemplate.opsForValue(); // 缓存 @@ -160,7 +167,14 @@ public class WxCouponController extends BaseController { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); } - String key = "ch:" + couponChannelId; + String key = "ch:"; + if(couponChannelIdL > 0){ + key = key + couponChannelIdL; + }else if(couponIdL > 0){ + key = key + couponIdL; + }else{ + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId/couponId为空"); + } ValueOperations operations = cdRedisTemplate.opsForValue(); // 缓存 diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java index 7e161f7f2..895f2221d 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java @@ -475,7 +475,7 @@ public class WxCouponOrderController extends BaseController { } WxCouponOrder couponOrder = null; try { - couponOrder = wxCouponOrderService.verify(wxCouponOrder); + couponOrder = wxCouponOrderService.verify(wxCouponOrder,null,EnumCouponVerifyType.VERIFY_C); } catch (MallinkException e) { logger.error("核销异常: " + e.getMessage()); return new ResultData(e.getErrorCode(), e.getMessage()); @@ -484,6 +484,10 @@ public class WxCouponOrderController extends BaseController { return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage()); } + if (couponOrder != null) { + wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId()); + } + return new ResultData(couponOrder); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java index 805707ca3..82ee5aff7 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponOrderExpiringSchedule.java @@ -112,6 +112,10 @@ public class CouponOrderExpiringSchedule { @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public void couponOrderExpire(WxCouponOrder co, boolean bStockBack) { + //商品订单不过期 + if(EnumCouponType.COUPON_DISTRIBUTION.getCode().equals(co.getCouponType())){ + return; + } // 标记 couponOrder过期 WxCouponOrder updateRecord = new WxCouponOrder(); updateRecord.setId(co.getId()); @@ -127,7 +131,8 @@ public class CouponOrderExpiringSchedule { // 库存退回 if(bStockBack) { WxOrder order = wxOrderMapper.selectById(co.getOrderId(),co.getTenantId()); - if(order != null) { + //券包子券没有库存 + if(order != null && order.getParentOrderId() == 0l) { wxOrderService.stockBack(order); } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java index 7ab4c659e..fc90fa0e9 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java @@ -61,7 +61,10 @@ public class WxCouponOrder extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="组合订单类型EnumComposeOrder",name="composeOrderType") private Integer composeOrderType; @io.swagger.annotations.ApiModelProperty(value="组合订单编号",name="composeOrderId") - private Long composeOrderId; + private Long composeOrderId; + + @io.swagger.annotations.ApiModelProperty(value="父订单编号",name="parentCouponOrderId") + private Long parentCouponOrderId; @io.swagger.annotations.ApiModelProperty(value="商品数量",name="couponNumber") private Integer couponNumber; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java index f7f4a0971..a67638368 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxOrder.java @@ -104,6 +104,10 @@ public class WxOrder extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="组合订单类型EnumComposeOrder",name="composeOrderType") private Integer composeOrderType; + @io.swagger.annotations.ApiModelProperty(value="父订单编号",name="parentOrderId") + private Long parentOrderId; + + @TableField(exist = false) diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java index 179ad8941..a07b193ca 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java @@ -21,7 +21,7 @@ public class WxCouponOrderBVo extends WxCouponOrder { private static final long serialVersionUID = 6687954932922444531L; - @Excel(name = "券码", width = 20, orderNum = "1", prefix = "`") + @Excel(name = "兑换码", width = 20, orderNum = "1", prefix = "`") protected Long id; /** 基础购买到的券信息 */ @@ -32,7 +32,7 @@ public class WxCouponOrderBVo extends WxCouponOrder { @io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime") private Date expiredTime; - @Excel(name = "券名称", width = 50, orderNum = "2") + @Excel(name = "券/商品名称", width = 50, orderNum = "2") @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") private String title; @@ -93,7 +93,7 @@ public class WxCouponOrderBVo extends WxCouponOrder { @io.swagger.annotations.ApiModelProperty(value="面额",name="price") private Integer price; - @Excel(name = "所属业态", width = 50, orderNum = "11", replace = {"餐饮_1", "娱乐_2", "服饰_3", "亲子_4", "超市_5", "其它_6", "美妆_7", "珠宝_8", "服务_9", "家居_10", "其它_"}) + @Excel(name = "所属业态", width = 50, orderNum = "11", replace = {"餐饮_1", "娱乐_2", "服饰_3", "亲子_4", "超市_5", "其它_6", "美妆_7", "珠宝_8", "服务_9", "家居_10", "_null"}) @io.swagger.annotations.ApiModelProperty(value = "业态", name = "business") private Integer business; @@ -134,7 +134,7 @@ public class WxCouponOrderBVo extends WxCouponOrder { private String bUserName; @io.swagger.annotations.ApiModelProperty(value="b端用户手机号",name="bUserPhone") private String bUserPhone; - @Excel(name = "券所属商户", width = 50, orderNum = "3") + @Excel(name = "所属商户", width = 50, orderNum = "3") @io.swagger.annotations.ApiModelProperty(value="使用券商户名",name="merchantName") private String merchantName; @@ -189,7 +189,7 @@ public class WxCouponOrderBVo extends WxCouponOrder { @TableField(exist = false) private Long couponId; - @Excel(name = "券类型", width = 50, orderNum = "15", replace = {"满减券_1", "代金券_2", "团购券_3", "礼品券_4", "停车券_5", "通用券_6", "砍价券_8", "团购券_9", "预购商品_10", "可配送商品_11", "券礼包_12", "积分券_50", "积分停车券_51", "消费卡_100"}) + @Excel(name = "类型", width = 50, orderNum = "15", replace = {"满减券_1", "代金券_2", "团购券_3", "礼品券_4", "停车券_5", "通用券_6", "砍价券_8", "团购券_9", "预购商品_10", "可配送商品_11", "券礼包_12", "积分券_50", "积分停车券_51", "消费卡_100"}) @TableField(exist = false) private Integer couponType; diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java index f9a12c6ae..4ff756555 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxOrderCouponVo.java @@ -117,6 +117,9 @@ public class WxOrderCouponVo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="组合订单编号",name="composeOrderId") private Long composeOrderId; + @io.swagger.annotations.ApiModelProperty(value="父订单编号",name="parentOrderId") + private Long parentOrderId; + @io.swagger.annotations.ApiModelProperty(value="商品数量",name="couponNumber") private Integer couponNumber; diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java index 764183525..32eba96d2 100644 --- a/mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java @@ -16,6 +16,8 @@ public enum EnumCouponVerifyType { VERIFY_POS_PAY(2, "POS交易核销"), VERIFY_C(3,"用户自主核销"), + + VERIFY_AUTO(4,"系统自动核销"), ; public static EnumCouponVerifyType getEnum(Integer code) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java index eeec70312..94b1e0b70 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java @@ -6,6 +6,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.*; +import com.iformall.enums.EnumCouponVerifyType; import com.iformall.enums.EnumPayWay; import com.iformall.service.order.entity.WxComposeOrder; @@ -55,15 +56,7 @@ public interface WxCouponOrderService { * @param couponOrder * @param bUser 核销人(登录用户) */ - WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser); - - /** - * 根据主键couponOrderId(券码)核销 - * C端自主核销 - * - * @param couponOrder - */ - WxCouponOrder verify(WxCouponOrder couponOrder); + WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser, EnumCouponVerifyType couponVerifyType); /** * 核销后发送消息 diff --git a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java index 2c0b459ac..8457fb8de 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxOrderService.java @@ -86,6 +86,13 @@ public interface WxOrderService { */ WxCouponOrder sendFreeCouponToUser(Long userId,TenantEntity tenantinfo,Long couponId, WxCouponSendVo wxCouponSendVo,EnumPayWay payWay,Long merchantId,Long bUserId); + /** + * 发券包子券 + * @param couponOrder + * @param couponIds + */ + void sendSubCouponToUser(WxCouponOrder couponOrder, List couponIds); + /** * orderSuccess 订单已支付 * @param updateOrder @@ -245,4 +252,5 @@ public interface WxOrderService { ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List composeOrderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity); PageInfo listGoodsCAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 2a7bbb2bb..6bab2bff8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -1,8 +1,8 @@ package com.iformall.service.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.aliyun.openservices.shade.com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; @@ -342,6 +342,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Override public void exportData(WxCouponOrderBVo wxCouponOrder, HttpServletRequest request, HttpServletResponse response) { String filename = "券订单"; + if(EnumCouponType.COUPON_DISTRIBUTION.getCode().equals(wxCouponOrder.getCouponType())){ + filename = "商品订单"; + } WxMerchant merchantQ = new WxMerchant(); merchantQ.updateTenantInfo(wxCouponOrder); List merchantList = wxMerchantMapper.findIdNameList(merchantQ); @@ -389,7 +392,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser) { + public WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser, EnumCouponVerifyType couponVerifyType) { + if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) && bUser == null){ + logger.error("B端核销未传入门店"); + throw new MallinkException(ErrorCode.VERIFY_ERROR); + } // 1. 获取券信息 WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); @@ -397,17 +404,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); } - - // 2. 检查适用门店 - WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); - wxCouponMerchant.setProductId(wxCoupon.getId()); - wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); - List couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); - if (!couponMerchantList.stream().anyMatch(cm -> cm.getMerchantId().equals(bUser.getMerchantId()))) { - logger.error("券: coupon-" + wxCoupon.getId() + "核销: couponMerchantId-" + bUser.getMerchantId()); - throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); - } - // 3. 券包状态检查 if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { logger.error("已过期: couponOrder-" + couponOrder.getId()); @@ -425,37 +421,88 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { logger.error("券已被预核销: couponOrder-" + couponOrder.getId()); throw new MallinkException(ErrorCode.COUPON_ORDER_IS_PRE_VERIFY); } - - //如果开启了分账,就必须要配置分账账号 - WxAppinfo appInfo = getAppinfo(couponOrder,couponOrder.getPayVendor()); - WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); - WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); - psReceiverQ.updateTenantInfo(payAccount); - psReceiverQ.setMerchantId(bUser.getMerchantId()); - psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor()).getProfitSharingType()); - psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); - List psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); - if (null == payAccount.getShare()) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该租户payAccount未设置分账."); - } - if (EnumPayShare.YES.getCode().intValue() == payAccount.getShare().intValue()) { - if (null == psReceiverList || psReceiverList.size() == 0) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号."); - }else { - for (WxProfitSharingReceiver receiver:psReceiverList) { - if (EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().intValue() - == receiver.getReceiverType().intValue()) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置."); - } - } - } + if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType())){ + logger.error("券为礼包卷: couponOrder-" + couponOrder.getId() ); + throw new MallinkException(ErrorCode.COUPON_ORDER_TYPE_NOT_SUPPORTED); + } + + // 2. 检查适用门店 + Long merchantId = null; + if(EnumCouponType.COUPON_DISTRIBUTION.getCode().equals(wxCoupon.getType())){ + //可配送商品 + WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); + wxCouponMerchant.setProductId(wxCoupon.getId()); + wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + WxCouponMerchant cm = null; + try{ + cm = wxCouponMerchantMapper.selectOne(new QueryWrapper<>(wxCouponMerchant)); + }catch (Exception e){ + throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); + } + if(cm == null){ + throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); + } + if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) && !cm.getId().equals(bUser.getMerchantId())){ + throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); + } + merchantId = cm.getId(); + }else if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType())){ + if (StringUtils.isBlank(wxCoupon.getGiftList())){ + logger.error("券包: coupon-" + wxCoupon.getId() + "数据异常" + "couponOrder-" + couponOrder.getId()); + throw new MallinkException(ErrorCode.COUPON_ORDER_DATE_ERROR); + } + if(!EnumCouponVerifyType.VERIFY_AUTO.equals(couponVerifyType)){ + throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); + } + }else{ + if(!EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType)){ + throw new MallinkException(ErrorCode.VERIFY_COUPON_TYPE_NOT_SUPPORT); + } + WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); + wxCouponMerchant.setProductId(wxCoupon.getId()); + wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + List couponMerchantList = wxCouponMerchantMapper.findList(wxCouponMerchant); + if (!couponMerchantList.stream().anyMatch(cm -> cm.getMerchantId().equals(bUser.getMerchantId()))) { + logger.error("券: coupon-" + wxCoupon.getId() + "核销: couponMerchantId-" + bUser.getMerchantId()); + throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); + } + merchantId = bUser.getId(); + } + + if(merchantId != null){ + //如果开启了分账,就必须要配置分账账号 + WxAppinfo appInfo = getAppinfo(couponOrder,couponOrder.getPayVendor()); + WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); + WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); + psReceiverQ.updateTenantInfo(payAccount); + psReceiverQ.setMerchantId(merchantId); + psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor()).getProfitSharingType()); + psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); + List psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); + if (null == payAccount.getShare()) { + throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该租户payAccount未设置分账."); + } + if (EnumPayShare.YES.getCode().intValue() == payAccount.getShare().intValue()) { + if (null == psReceiverList || psReceiverList.size() == 0) { + throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号."); + }else { + for (WxProfitSharingReceiver receiver:psReceiverList) { + if (EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().intValue() + == receiver.getReceiverType().intValue()) { + throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置."); + } + } + } + } } + int num = 0; try { couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); //1核销 - couponOrder.setBUserId(bUser.getId()); - couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_B.getCode()); - if(StringUtils.isNotBlank(couponOrder.getVerifyRemark())){ + couponOrder.setBUserId(bUser==null?0l:bUser.getId()); + couponOrder.setVerifyType(couponVerifyType.getCode()); + if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) + && StringUtils.isNotBlank(couponOrder.getVerifyRemark())){ if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_11.getCode().toString())){ couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_11.getMessage()); }else if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_12.getCode().toString())){ @@ -477,97 +524,24 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { logger.error("核销异常:updatete num " + num); throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); } - doAfterVerify(couponOrder, bUser, wxCoupon); - return couponOrder; - } - @Override - @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public WxCouponOrder verify(WxCouponOrder couponOrder) { - - // 1. 获取券信息 - WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); - if (wxCoupon == null) { - logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); - } - - // 2. 检查适用门店(自主核销有且只有一个门店) - WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); - wxCouponMerchant.setProductId(wxCoupon.getId()); - wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); - WxCouponMerchant cm = null; - try{ - cm = wxCouponMerchantMapper.selectOne(new QueryWrapper<>(wxCouponMerchant)); - }catch (Exception e){ - throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); - } - if(cm == null){ - throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); - } - - // 3. 券包状态检查 - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { - logger.error("已过期: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()) { - logger.error("已退款: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { - logger.error("已经核销过的券: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.POS_PRE_VERIFY.getCode()) { - logger.error("券已被预核销: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_PRE_VERIFY); - } - - //如果开启了分账,就必须要配置分账账号 - WxAppinfo appInfo = getAppinfo(couponOrder,couponOrder.getPayVendor()); - WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); - WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); - psReceiverQ.updateTenantInfo(payAccount); - psReceiverQ.setMerchantId(cm.getMerchantId()); - psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor()).getProfitSharingType()); - psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); - List psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); - if (null == payAccount.getShare()) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该租户payAccount未设置分账."); - } - if (EnumPayShare.YES.getCode().intValue() == payAccount.getShare().intValue()) { - if (null == psReceiverList || psReceiverList.size() == 0) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号."); - }else { - for (WxProfitSharingReceiver receiver:psReceiverList) { - if (EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().intValue() - == receiver.getReceiverType().intValue()) { - throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置."); - } - } - } - } - int num = 0; - try { - couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); //1核销 - couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_C.getCode()); - if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){ - couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_SELF_MENTION.getCode()); - }else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){ - couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_DISTRIBUTION.getCode()); + if(EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType())){ + try { + List longs = JSON.parseArray(wxCoupon.getGiftList(), Long.class); + //发券包子券 + wxOrderService.sendSubCouponToUser(couponOrder,longs); + } catch (MallinkException e) { + throw e; + } catch (Exception e){ + throw new MallinkException(ErrorCode.COUPON_ORDER_SEND_ERROR.getCode(), couponOrder.getCouponName() + ErrorCode.COUPON_ORDER_SEND_ERROR.getMessage() ); } - couponOrder.setUpdateDate(new Date()); - num = wxCouponOrderMapper.updateVerifyCouponOrder(couponOrder); - } catch (Exception e) { - logger.error("db failed: couponOrder-" + couponOrder.getId() + ", e:" + e.getMessage()); - throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); } - if (num != 1) { - logger.error("核销异常:updatete num " + num); - throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); + + if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType)){ + doAfterVerify(couponOrder, bUser, wxCoupon); + }else{ + doAfterVerify(couponOrder, wxCoupon, merchantId); } - doAfterVerify(couponOrder, wxCoupon, cm.getMerchantId()); - this.sendInsideCouponVerifyMsg(couponOrder, couponOrder.getId(), cm.getMerchantId()); + couponOrder.setMerchantId(merchantId); return couponOrder; } @@ -680,7 +654,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { creditHistory.setSpend(couponOrder.getCouponPrice()); //如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 creditHistory.setMerchantId(merchantId); - creditHistory.setChangePurpose("用户自主核销增加积分:券名称["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] "); + creditHistory.setChangePurpose("增加积分:券名称["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] "); wxCreditHistoryService.saveOrUpdate(creditHistory,couponOrder.getTenantId()); } catch (Exception e) { logger.error("积分值:" + e.getMessage()); @@ -915,6 +889,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { // 补贴已入库 return; } + subsidyNum = subsidyNum * couponOrder.getCouponNumber(); // 新补贴入库 int iSubChargeFee = OrderHelper.getMallCharge(subsidyNum, payAccount); Integer realSubsidyFee = subsidyNum - iSubChargeFee; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 410ba58b0..cb4b2c1ab 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -114,6 +114,9 @@ public class WxOrderServiceImpl implements WxOrderService { @Autowired WxCouponOrderMapper wxCouponOrderMapper; + @Autowired + WxCouponOrderService wxCouponOrderService; + @Autowired WxCUserService wxCUserService; @@ -986,7 +989,7 @@ public class WxOrderServiceImpl implements WxOrderService { * @param coupon */ @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public WxCouponOrder createCouponOrder(WxOrder order, WxCUserBasicInfo user, WxCoupon coupon, Long couponPasswordId,EnumPayWay payWay,Long merchantId,Long bUserId) { + public WxCouponOrder createCouponOrder(WxOrder order, WxCUserBasicInfo user, WxCoupon coupon, Long couponPasswordId,EnumPayWay payWay,Long merchantId,Long bUserId,Long parentCouponOrderId) { Date curr = new Date(); Date valid_date = null; int limit_days = Constant.WX_LIMIT_DAYS; @@ -1065,7 +1068,7 @@ public class WxOrderServiceImpl implements WxOrderService { couponOrder.setCUserId(user.getId()); couponOrder.setOwnerId(user.getId()); couponOrder.setAutoRefund(coupon.getAutoRefund()); - couponOrder.setOrderId(order.getOrderNumber()); + couponOrder.setOrderId(order.getId()); couponOrder.setExpiredTime(valid_date); if (null != merchantId) { couponOrder.setSendMerchantId(merchantId); @@ -1077,6 +1080,8 @@ public class WxOrderServiceImpl implements WxOrderService { couponOrder.setComposeOrderId(order.getComposeOrderId()); couponOrder.setCouponNumber(order.getCouponNumber()); + couponOrder.setParentCouponOrderId(parentCouponOrderId); + couponOrder.setFreightPrice(order.getFreightPrice()); couponOrder.setShippingType(order.getShippingType()); couponOrder.setShippingAddress(order.getShippingAddress()); @@ -1205,7 +1210,7 @@ public class WxOrderServiceImpl implements WxOrderService { couponOrder.setCUserId(user.getId()); couponOrder.setOwnerId(user.getId()); couponOrder.setAutoRefund(coupon.getAutoRefund()); - couponOrder.setOrderId(order.getOrderNumber()); + couponOrder.setOrderId(order.getId()); couponOrder.setExpiredTime(valid_date); if (!isCard) { couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); @@ -1298,25 +1303,19 @@ public class WxOrderServiceImpl implements WxOrderService { throw new MallinkException(ErrorCode.COUPON_IS_NOT_FREE.getCode(), coupon.getTitle() + ErrorCode.COUPON_IS_NOT_FREE.getMessage()); } - Integer composeOrderType = EnumComposeOrder.SINGLE.getCode(); - if(EnumPayWay.PAY_WAY_NOT_UNPAY_GIFTLIST.equals(payWay)){ - composeOrderType = EnumComposeOrder.PACKAGECOUPON.getCode(); - }else{ - composeOrderType = EnumComposeOrder.SINGLE.getCode(); - if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { - // 商户注券减库存操作 - try { - stockMerchantReduce(user, coupon, couponIdStr, wxCouponSendVo); - }catch(Exception e) { - throw new MallinkException(ErrorCode.COUPON_STOCK_ERR.getCode(), e.getMessage()); - } - } else { - // 减库存操作 - try { - stockReduce(false,user, coupon, couponIdStr,1); - }catch(Exception e) { - throw new MallinkException(ErrorCode.COUPON_STOCK_ERR.getCode(), e.getMessage()); - } + if (Objects.nonNull(wxCouponSendVo) && Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), wxCouponSendVo.getSendType())) { + // 商户注券减库存操作 + try { + stockMerchantReduce(user, coupon, couponIdStr, wxCouponSendVo); + }catch(Exception e) { + throw new MallinkException(ErrorCode.COUPON_STOCK_ERR.getCode(), e.getMessage()); + } + } else { + // 减库存操作 + try { + stockReduce(false,user, coupon, couponIdStr,1); + }catch(Exception e) { + throw new MallinkException(ErrorCode.COUPON_STOCK_ERR.getCode(), e.getMessage()); } } @@ -1345,7 +1344,7 @@ public class WxOrderServiceImpl implements WxOrderService { record.setCreateDate(curr); record.setUpdateDate(curr); record.setComposeOrderId(0L); - record.setComposeOrderType(composeOrderType); + record.setComposeOrderType(EnumComposeOrder.SINGLE.getCode()); record.setCouponNumber(1); // 保存订单 try { @@ -1358,7 +1357,7 @@ public class WxOrderServiceImpl implements WxOrderService { // 创建couponOrder WxCouponOrder couponOrder = null; try { - couponOrder = createCouponOrder(record, user, coupon, null,payWay,merchantId,bUserId); + couponOrder = createCouponOrder(record, user, coupon, null,payWay,merchantId,bUserId,null); } catch (Exception e) { logger.error("保存订单:" + e.getMessage()); throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.COUPON_ORDER_SAVE_ERR.getMessage()); @@ -1367,6 +1366,80 @@ public class WxOrderServiceImpl implements WxOrderService { return couponOrder; } + @Override + @Transactional(propagation = Propagation.NESTED, readOnly = false, rollbackFor = {Exception.class}) + public void sendSubCouponToUser(WxCouponOrder couponOrder, List couponIds) { + // check 用户状态 + WxCUserBasicInfo user = null; + try { + user = wxCUserBasicInfoMapper.selectById(couponOrder.getcUserId(),couponOrder.getFinalTenantId()); + } catch (Exception e) { + logger.error("userId : " + couponOrder.getcUserId() + ", e: " + e.getMessage(),e); + } + if (user == null) { + logger.error("用户不存在, userId: " + couponOrder.getcUserId()); + throw new MallinkException(ErrorCode.USER_IS_EMPTY); + } + for (Long couponId:couponIds) { + WxCoupon coupon = wxCouponMapper.selectById(couponId,couponOrder.getTenantId()); + if (coupon == null) { + logger.error("券不存在, couponId: " + couponId); + throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); + } + if (coupon.getStatus() == EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode()) { + logger.error("券已下架, couponId: " + couponId); + throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(), coupon.getTitle() + ErrorCode.COUPON_IS_TAKE_OFF.getMessage()); + } + if (coupon.getSendType() != 3 || coupon.getSalePrice() != 0) { + logger.error("券 sendType 错误, couponId: " + couponId); + throw new MallinkException(ErrorCode.COUPON_VALID_NOT_SUPPORTED.getCode(), coupon.getTitle() + ErrorCode.COUPON_IS_NOT_FREE.getMessage()); + } + + Date curr = new Date(); + + final IdWorker idWorker = IdWorker.get(); + Long orderNumber = idWorker.nextId(); + + // body + // tenant_id + merchant_id + title + subtitle + String bodyStr = coupon.getTitle() + "/" + coupon.getSubTitle(); + + WxOrder record = new WxOrder(); + record.setId(orderNumber); + record.updateTenantInfo(coupon); + record.setOrderNumber(orderNumber); + record.setProductId(couponId); + record.setType(EnumOrderType.COUPON.getCode()); + record.setCUserId(user.getId()); + record.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); + record.setPayment(coupon.getSalePrice()); + record.setOrderStatus(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); + record.setDetail(bodyStr); + record.setCreateDate(curr); + record.setUpdateDate(curr); + record.setComposeOrderId(0L); + record.setComposeOrderType(EnumComposeOrder.PACKAGECOUPON.getCode()); + record.setParentOrderId(couponOrder.getOrderId()); + record.setCouponNumber(1); + // 保存订单 + try { + wxOrderMapper.insert(record); + } catch (Exception e) { + logger.error("保存订单:" + e.getMessage()); + throw new MallinkException(ErrorCode.ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.ORDER_SAVE_ERR.getMessage()); + } + + // 创建couponOrder + try { + createCouponOrder(record, user, coupon, null,EnumPayWay.PAY_WAY_NOT_UNPAY_GIFTLIST,null,null,couponOrder.getId()); + } catch (Exception e) { + logger.error("保存订单:" + e.getMessage()); + throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(), coupon.getTitle() + ErrorCode.COUPON_ORDER_SAVE_ERR.getMessage()); + } + + } + } + @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public WxCouponOrder couponOrderSuccess(WxOrder updateOrder) { @@ -1406,7 +1479,7 @@ public class WxOrderServiceImpl implements WxOrderService { // 创建couponOrder try { - return createCouponOrder(updateOrder, user, coupon, null,null,null,null); + return createCouponOrder(updateOrder, user, coupon, null,null,null,null,null); } catch (Exception e) { logger.error("创建券包:" + e.getMessage()); throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR); @@ -1468,17 +1541,33 @@ public class WxOrderServiceImpl implements WxOrderService { /** * 下订单后操作 * - * @param updateOrder + * @param order * @param coupon * @param user */ - public void actionAfterCouponOrderSuccess(WxOrder updateOrder, WxCoupon coupon, WxCUserBasicInfo user) { + public void actionAfterCouponOrderSuccess(WxOrder order, WxCoupon coupon, WxCUserBasicInfo user) { + if(EnumCouponType.COUPON_GIFT.getCode().equals(coupon.getType())){ + WxCouponOrder couponOrderQ = new WxCouponOrder(); + couponOrderQ.setOrderId(order.getId()); + couponOrderQ.setCouponId(coupon.getId()); + couponOrderQ.updateTenantInfo(order); + List couponorderlist = wxCouponOrderMapper.findList(couponOrderQ); + if (null != couponorderlist && couponorderlist.size() > 0 ) { + WxCouponOrder couponOrder = couponorderlist.get(0); + try { + wxCouponOrderService.verify(couponOrder,null,EnumCouponVerifyType.VERIFY_AUTO); + } catch (Exception e) { + logger.error("系统券包核销异常:" + e.getMessage()); + } + } + + } /// TODO 晚上会定时打一下tag - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_BUY, user,updateOrder,null); + wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_BUY, user,order,null); // 交易发券 try { - wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.C_ORDER, updateOrder,EnumPayWay.PAY_WAY_NOT_UNPAY_TRADE); + wxCouponSendService.sendCouponToUser(EnumCouponSendSendType.C_ORDER, order,EnumPayWay.PAY_WAY_NOT_UNPAY_TRADE); } catch (Exception e) { logger.error("订单发券:" + e.getMessage()); } @@ -2166,7 +2255,7 @@ public class WxOrderServiceImpl implements WxOrderService { } // 5. 创建couponOrder try { - proxy.createCouponOrder(record, user, coupon, couponPasswordId,payWay,null,null); + proxy.createCouponOrder(record, user, coupon, couponPasswordId,payWay,null,null,null); } catch (Exception e) { logger.error("couponOrder失败:" + e.getMessage(),e); throw new MallinkException(ErrorCode.COUPON_ORDER_SAVE_ERR.getCode(),"["+coupon.getTitle()+"]保存券订单错误."+e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index 3d7cec53a..376f5a216 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -897,8 +897,11 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { // 普通券, 修改订单状态 try { WxCouponOrder couponOrder = wxOrderService.couponOrderSuccess(order); - - orderFactory.getOrderAdapterService(record.getComposeOrder()).doOthersAfterPaySuccess(order, record,couponOrder); + try{ + orderFactory.getOrderAdapterService(record.getComposeOrder()).doOthersAfterPaySuccess(order, record,couponOrder); + }catch (Exception e) { + logger.error("doOthersAfterPaySuccess----error"+e.getMessage()); + } } catch (Exception e) { logger.error(e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java b/mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java index d8b40c282..95fbe28f2 100644 --- a/mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java +++ b/mallinkService/src/main/java/com/iformall/service/order/impl/batch/CouponPackageOrderAdapterService.java @@ -55,53 +55,8 @@ public class CouponPackageOrderAdapterService extends BaseBatchOrderAdapterServi @Override @Async - @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) + @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = {Exception.class}) public void doOthersAfterPaySuccess(WxOrder order, WxPayOrder record, WxCouponOrder couponOrder) { - WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(), couponOrder.getTenantId()); - if (wxCoupon == null || !EnumCouponType.COUPON_GIFT.getCode().equals(wxCoupon.getType())) { - logger.error("券包: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); - } - if (StringUtils.isBlank(wxCoupon.getGiftList())){ - logger.error("券包: coupon-" + wxCoupon.getId() + "数据异常" + "couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_DATE_ERROR); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { - logger.error("已过期: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()) { - logger.error("已退款: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { - logger.error("已经核销过的券: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); - } - if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.POS_PRE_VERIFY.getCode()) { - logger.error("券已被预核销: couponOrder-" + couponOrder.getId()); - throw new MallinkException(ErrorCode.COUPON_ORDER_IS_PRE_VERIFY); - } - - //核销券包 - couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); //1核销 - couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_C.getCode()); - couponOrder.setUpdateDate(new Date()); - int num = wxCouponOrderMapper.updateVerifyCouponOrder(couponOrder); - if (num != 1) { - throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); - } - try { - List longs = JSON.parseArray(wxCoupon.getGiftList(), Long.class); - //发券包子券 - for (Long couponId:longs) { - wxOrderService.sendFreeCouponToUser(couponOrder.getCUserId(),couponOrder,couponId,null,EnumPayWay.PAY_WAY_NOT_UNPAY_GIFTLIST,null,null); - } - } catch (MallinkException e) { - throw e; - } catch (Exception e){ - throw new MallinkException(ErrorCode.COUPON_ORDER_SEND_ERROR.getCode(), couponOrder.getCouponName() + ErrorCode.COUPON_ORDER_SEND_ERROR.getMessage() ); - } } @@ -109,5 +64,5 @@ public class CouponPackageOrderAdapterService extends BaseBatchOrderAdapterServi public String getPayProductName(WxCoupon lastCoupon) { return "[券包]"+lastCoupon.getTitle(); } - + } diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 43475cea0..bdbf438b4 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -730,7 +730,9 @@ update wx_coupon c SET c.status = 1, c.update_date = now() - where c.status = 0 and c.tenant_id =#{tenantId} + where c.status = 0 and c.tenant_id =#{tenantId} + + and c.type != 12 and c.id not in diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index c2735cf9f..f3fe68c84 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -24,6 +24,7 @@ + @@ -35,7 +36,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_type`,`c_user_id`,`owner_id`,`b_user_id`,`order_id`,`expired_time`,`coupon_order_status`,`create_date`,`update_date`,`coupon_price`, `auto_refund`, - `verify_type`,`verify_remark`,`pay_vendor`,`send_merchant_id`,`send_merchant_user_id`,`compose_order_type`,`compose_order_id`,`coupon_number`, + `verify_type`,`verify_remark`,`pay_vendor`,`send_merchant_id`,`send_merchant_user_id`,`compose_order_type`,`compose_order_id`,`parent_coupon_order_id`,`coupon_number`, `freight_price`,`shipping_type`,`shipping_address`,`shipping_status`,`delivery_info` @@ -121,6 +122,10 @@ and `compose_order_id` = #{composeOrderId} + + and `parent_coupon_order_id` = #{parentCouponOrderId} + + and `shipping_type` = #{shippingType} diff --git a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml index a4d51d27e..01adaa994 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml @@ -29,11 +29,12 @@ + `id`,`order_number`,`tenant_id`,`parent_tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`payment_type`,`payment`,`payment_time`,`freight_price`,`order_status`,`create_date`,`update_date`,`detail`, - `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`,`form_id`,`total_payment`,`compose_order_id`,`coupon_number`,`compose_order_type`,`shipping_type`,`shipping_address` + `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`,`form_id`,`total_payment`,`compose_order_id`,`coupon_number`,`compose_order_type`,`shipping_type`,`shipping_address`,`parent_order_id` @@ -129,6 +130,10 @@ and `shipping_type` = #{shippingType} + + + and `parent_order_id` = #{parentOrderId} + and `order_status` in @@ -265,7 +270,7 @@ o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.gift_list, - co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id, + co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id,o.parent_order_id, o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,co.`shipping_status`,co.`delivery_info` @@ -351,6 +356,7 @@ + @@ -404,6 +410,7 @@ + @@ -428,7 +435,7 @@ o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, o.compose_order_type,o.compose_order_id, - o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` + o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,o.parent_order_id