| @@ -0,0 +1,2 @@ | |||
| ALTER TABLE `wx_order` | |||
| ADD COLUMN `form_id` VARCHAR(64) NULL COMMENT 'formId' AFTER `order_group_id`; | |||
| @@ -39,13 +39,14 @@ public class WxOrderController extends BaseController { | |||
| @Autowired | |||
| private WxOrderService wxOrderService; | |||
| @ApiOperation(value = "免费领取", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\"}") | |||
| @ApiOperation(value = "免费领取", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"formId\":\"String\"}") | |||
| @PostMapping("freeCoupon") | |||
| public ResultData freeCoupon(@RequestBody Map<String, String> paramMap) { | |||
| //Assert.notNull(wxOrders.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| String couponChannelIdStr = paramMap.get("couponChannelId"); | |||
| String couponIdStr = paramMap.get("couponId"); | |||
| String formId = paramMap.get("formId"); | |||
| if (StringUtils.isBlank(couponChannelIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空"); | |||
| } | |||
| @@ -72,7 +73,7 @@ public class WxOrderController extends BaseController { | |||
| WxOrder order = null; | |||
| try { | |||
| order = wxOrderService.saveFreeCouponOrder(getUserId(), couponChannelId, couponId); | |||
| order = wxOrderService.saveFreeCouponOrder(getUserId(), couponChannelId, couponId, formId); | |||
| return new ResultData(order); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -83,7 +84,7 @@ public class WxOrderController extends BaseController { | |||
| } | |||
| } | |||
| @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\"}") | |||
| @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") | |||
| @PostMapping("save") | |||
| public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("OrderSave: " + paramMap.toString()); | |||
| @@ -93,6 +94,7 @@ public class WxOrderController extends BaseController { | |||
| String couponIdStr = paramMap.get("couponId"); | |||
| String pressStr = paramMap.get("press"); | |||
| String orderGroupIdStr = paramMap.get("orderGroupId"); | |||
| String formId = paramMap.get("formId"); | |||
| if (StringUtils.isBlank(couponChannelIdStr)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空"); | |||
| @@ -165,7 +167,7 @@ public class WxOrderController extends BaseController { | |||
| WxCUser user = getUser(); | |||
| try { | |||
| WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId, isPress, orderGroupId); | |||
| WxOrder order = wxOrderService.saveCouponOrder(user, couponChannelId, couponId, isPress, orderGroupId, formId); | |||
| return new ResultData(order); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -48,65 +48,52 @@ public class WxOrder implements Serializable { | |||
| @Transient | |||
| private String phone; | |||
| /**订单码;正反向交易保持一致。**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") | |||
| private Long orderNumber; | |||
| /**租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /**c端用户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId") | |||
| private Long cUserId; | |||
| /**渠道ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="渠道ID",name="couponChannelId") | |||
| private Long couponChannelId; | |||
| /**产品ID,根据order type**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="产品ID(type-0:couponId, 1:buserId, 3:merchantId)",name="productId") | |||
| private Long productId; | |||
| /**类型0:券,1:B刷卡支付,2:C扫码支付,3:储值卡**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="类型",name="type") | |||
| @io.swagger.annotations.ApiModelProperty(value="类型(0:券,1:B刷卡支付,2:C扫码支付,3:储值卡)",name="type") | |||
| private Integer type; | |||
| /**0: 付款 1: 退款**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType") | |||
| private Integer paymentType; | |||
| /**支付金额(分):允许有负数,退款时为负值。**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付金额(分):允许有负数,退款时为负值。",name="payment") | |||
| private Integer payment; | |||
| /**支付时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime") | |||
| private Date paymentTime; | |||
| /**订单状态:-1全部;正向交易:0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易:3-待退款;4-已退款,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单状态:-1全部;正向交易:0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易:3-已退款; 4-退款失败,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败",name="orderStatus") | |||
| private Integer orderStatus; | |||
| /**创建时间/砍价开始时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate") | |||
| private Date createDate; | |||
| /**更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| /**支付描述,订单支付时用**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="支付描述,订单支付时用",name="detail") | |||
| private String detail; | |||
| /**砍价结束时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="砍价结束时间",name="pressEndDate") | |||
| private Date pressEndDate; | |||
| /**砍价人数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="砍价人数",name="pressCurrentNum") | |||
| private Integer pressCurrentNum; | |||
| /**已砍价格**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="已砍价格",name="pressCurrentValue") | |||
| private Integer pressCurrentValue; | |||
| @io.swagger.annotations.ApiModelProperty(value = "拼团ID", name = "orderGroupId") | |||
| private Long orderGroupId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "formId", name = "formId") | |||
| private String formId; | |||
| @Transient | |||
| protected List<Integer> statusS; | |||
| @Transient | |||
| protected String statusStr; | |||
| @io.swagger.annotations.ApiModelProperty(value = "拼团ID", name = "orderGroupId") | |||
| private Long orderGroupId; | |||
| public Long getOrderNumber() { | |||
| return orderNumber; | |||
| @@ -275,7 +262,15 @@ public class WxOrder implements Serializable { | |||
| this.orderGroupId = orderGroupId; | |||
| } | |||
| public static enum Field | |||
| public String getFormId() { | |||
| return formId; | |||
| } | |||
| public void setFormId(String formId) { | |||
| this.formId = formId; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,OrderNumber_ASC("`order_number` ASC"),OrderNumber_DESC("`order_number` DESC") | |||
| @@ -21,21 +21,15 @@ public class WxTemplateMsg implements Serializable { | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| /**租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| private String tenantId; | |||
| /**模板ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="模板ID",name="templateId") | |||
| private String templateId; | |||
| /**模板类型1:核销成功消息, 2:核销失败消息**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息",name="type") | |||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息, 101:公众号审核结果消息, 102:公众号卡券核销消息",name="type") | |||
| private Integer type; | |||
| /**创建时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| /**更新时间**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @@ -33,6 +33,14 @@ public interface WxOrderService { | |||
| ResultData microPayListOnDateAsPage(Long bUserId, Integer type, String date, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 下免费券订单接口 | |||
| * @param userId | |||
| * @param couponId | |||
| * @return WxOrder | |||
| */ | |||
| WxOrder saveFreeCouponOrder(Long userId, Long couponChannelId, Long couponId, String formId); | |||
| /** | |||
| * 提交订单 | |||
| * @param user | |||
| @@ -40,7 +48,7 @@ public interface WxOrderService { | |||
| * @param orderGroupId | |||
| * @return 订单id | |||
| */ | |||
| WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress, Long orderGroupId); | |||
| WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress, Long orderGroupId, String formId); | |||
| /** | |||
| * 付款码支付 | |||
| @@ -60,14 +68,6 @@ public interface WxOrderService { | |||
| */ | |||
| WxOrder saveCardPayOrder(WxMerchant merchant, Long cUserId, String totalFeeStr, Integer payment); | |||
| /** | |||
| * 免费券订单接口 | |||
| * @param userId | |||
| * @param couponId | |||
| * @return WxOrder | |||
| */ | |||
| WxOrder saveFreeCouponOrder(Long userId, Long couponChannelId, Long couponId); | |||
| /** | |||
| * 免费券订单接口 | |||
| * @param userId | |||
| @@ -26,6 +26,7 @@ import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.MaUtil; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.poi.ss.usermodel.Workbook; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -535,16 +536,16 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| logger.error("找不到订单信息"); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| String formId = null; | |||
| if(StringUtils.isNotBlank(order.getFormId())) { | |||
| formId = order.getFormId(); | |||
| } | |||
| // 2. get coupon info | |||
| WxCoupon coupon = wxCouponMapper.selectByPrimaryKey(couponOrder.getCouponId()); | |||
| if (coupon == null) { | |||
| logger.error("找不到券信息"); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if(coupon.getSalePrice().equals(0)) { | |||
| logger.info("免费券不发模板消息!"); | |||
| return; | |||
| } | |||
| // 3. merchant info | |||
| WxMerchant merchant = wxMerchantMapper.selectByPrimaryKey(bUser.getMerchantId()); | |||
| if (merchant == null) { | |||
| @@ -562,26 +563,27 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| // WxAppinfo appInfo = wxAppinfoService.getByAppId(user.getAppId()); | |||
| // 6. get payOrder info | |||
| WxPayOrder payOrder = null; | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(couponOrder.getTenantId()); | |||
| payOrderQ.setOrderId(order.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| List<WxPayOrder> payList = wxPayOrderMapper.select(payOrderQ); | |||
| if (payList.size() > 0) { | |||
| payOrder = payList.get(0); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("找不到payOrder信息"); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| if (payOrder.getPrepayId() == null) { | |||
| logger.error("payOrder信息中,prepay_id为空"); | |||
| throw new MallinkException(ErrorCode.PREPAY_ID_IS_EMPTY); | |||
| if(StringUtils.isBlank(order.getFormId())) { | |||
| WxPayOrder payOrder = null; | |||
| WxPayOrder payOrderQ = new WxPayOrder(); | |||
| payOrderQ.setTenantId(couponOrder.getTenantId()); | |||
| payOrderQ.setOrderId(order.getId()); | |||
| payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| List<WxPayOrder> payList = wxPayOrderMapper.select(payOrderQ); | |||
| if (payList.size() > 0) { | |||
| payOrder = payList.get(0); | |||
| } | |||
| if (payOrder == null) { | |||
| logger.error("找不到payOrder信息"); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| if (payOrder.getPrepayId() == null) { | |||
| logger.error("payOrder信息中,prepay_id为空"); | |||
| throw new MallinkException(ErrorCode.PREPAY_ID_IS_EMPTY); | |||
| } | |||
| formId = payOrder.getPrepayId(); | |||
| } | |||
| // WxMaService wxMaService = MaUtil.getWeappService(appInfo); | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||
| String couponDetail = ""; | |||
| if (coupon.getType() == EnumCouponType.COUPON_MANJIAN.getCode()) { | |||
| @@ -596,7 +598,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| gotopage = "pages/couponorder/index/index"; | |||
| notes = "您有新的券"; | |||
| } | |||
| //mq发送小程序消息 | |||
| //mq发送小程序消息 - 核销成功消息 | |||
| smartAppMsg = new SmartAppMsg(); | |||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||
| smartAppMsg.setAppId(user.getAppId()); | |||
| @@ -604,7 +606,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_SUCCESS.getCode()); | |||
| smartAppMsg.setGotopage(gotopage); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setFrom(payOrder.getPrepayId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("keyword1", coupon.getPriceStr() + "元", "#173177"), | |||
| new WxMaTemplateData("keyword2", merchant.getName(), "#173177"), | |||
| @@ -615,7 +617,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| new WxMaTemplateData("keyword7", notes, "#173177"))); | |||
| smartAppMsg.setEmphasisKeyword("keyword1.DATA"); | |||
| } else { | |||
| //mq发送小程序消息 | |||
| //mq发送小程序消息 - 核销失败消息 | |||
| smartAppMsg = new SmartAppMsg(); | |||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||
| smartAppMsg.setAppId(user.getAppId()); | |||
| @@ -624,7 +626,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| smartAppMsg.setGotopage("pages/index/index"); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setReceiver(user.getOpenId()); | |||
| smartAppMsg.setFrom(payOrder.getPrepayId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("keyword1", coupon.getTitle(), "#173177"), | |||
| new WxMaTemplateData("keyword2", dateFormat.format(new Date()), "#173177"), | |||
| @@ -337,7 +337,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress, Long orderGroupId) { | |||
| public WxOrder saveCouponOrder(WxCUser user, Long couponChannelId, Long couponId, boolean isPress, Long orderGroupId, String formId) { | |||
| // 检查用户 | |||
| if (user == null) { | |||
| logger.error("用户不存在"); | |||
| @@ -428,6 +428,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setCreateDate(curr); | |||
| record.setUpdateDate(curr); | |||
| record.setOrderGroupId(orderGroupId); | |||
| record.setFormId(formId); | |||
| if (isPress) { | |||
| // 初始砍价信息 | |||
| @@ -688,7 +689,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxOrder saveFreeCouponOrder(Long userId, Long couponChannelId, Long couponId) { | |||
| public WxOrder saveFreeCouponOrder(Long userId, Long couponChannelId, Long couponId, String formId) { | |||
| // check 用户状态 | |||
| WxCUser user = null; | |||
| try { | |||
| @@ -750,6 +751,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| record.setDetail(bodyStr); | |||
| record.setCreateDate(curr); | |||
| record.setUpdateDate(curr); | |||
| record.setFormId(formId); | |||
| // 保存订单 | |||
| try { | |||
| @@ -20,12 +20,13 @@ | |||
| <result column="press_current_num" jdbcType="INTEGER" property="pressCurrentNum"/> | |||
| <result column="press_current_value" jdbcType="INTEGER" property="pressCurrentValue"/> | |||
| <result column="order_group_id" jdbcType="BIGINT" property="orderGroupId"/> | |||
| <result column="form_id" jdbcType="VARCHAR" property="formId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`order_number`,`tenant_id`,`c_user_id`,`coupon_channel_id`,`product_id`,`type`,`payment_type`,`payment`,`payment_time`,`order_status`,`create_date`,`update_date`,`detail`, | |||
| `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id` | |||
| `press_end_date`,`press_current_num`,`press_current_value`,`order_group_id`,`form_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -102,6 +103,10 @@ | |||
| <if test=" null != orderGroupId "> | |||
| and `order_group_id` = #{orderGroupId} | |||
| </if> | |||
| <if test=" null != formId "> | |||
| and `form_id` = #{formId} | |||
| </if> | |||
| <if test=" null != statusS "> | |||
| and `order_status` in | |||