# Conflicts: # mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.javarelease_toaliyun_real
| @@ -57,8 +57,7 @@ public class WxBillPropertyController extends BaseController { | |||
| @SystemControllerLog(description = "物业账单-更新") | |||
| public ResultData update(@RequestBody WxBillProperty wxBillProperty) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillPropertyController::update"); | |||
| wxBillPropertyService.saveOrUpdate(wxBillProperty, getUser()); | |||
| return new ResultData(); | |||
| return wxBillPropertyService.saveOrUpdate(wxBillProperty, getUser()); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -106,6 +106,8 @@ public class WxOrderController extends BaseController { | |||
| WxCUserBasicInfo cUserBasicInfo = wxCUserBasicInfoService.getById(user.getId()); | |||
| if (cUserBasicInfo != null && cUserBasicInfo.getActRecord() > 0) | |||
| return new ResultData(ErrorCode.COUPON_ONLY_FOR_NEW_MEMBER); | |||
| if (wxOrderService.countCouponConditionType1(user) > 0) | |||
| return new ResultData(ErrorCode.COUPON_ALREADY_IN_NEW_MEMBER); | |||
| }else if (jo.getIntValue("type") == EnumCouponConditionType.SCORE_SCOPE.getCode()){ | |||
| int max = jo.getIntValue("max"); | |||
| int min = jo.getIntValue("min"); | |||
| @@ -11,9 +11,14 @@ import com.iformall.enums.EnumBoxRegisterStatus; | |||
| import com.iformall.service.kw.KwBoxCmdHistoryService; | |||
| import com.iformall.service.kw.KwBoxService; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.Utility; | |||
| import com.sun.crypto.provider.HmacSHA1; | |||
| import io.netty.util.internal.StringUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.codec.digest.HmacAlgorithms; | |||
| import org.apache.commons.codec.digest.HmacUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -82,13 +87,13 @@ public class KwBoxV1Controller extends BaseController { | |||
| record.setUpdateTime(new Date()); | |||
| record.setRegisterTime(new Date()); | |||
| record.setLastOnlineTime(new Date()); | |||
| record.setComKey(Utility.generate32UUID()); | |||
| record.setRegisterStatus(EnumBoxRegisterStatus.REGISTERED.getCode()); | |||
| kwBoxService.saveOrUpdate(record); | |||
| Map<String,Object> data = new HashMap<>(); | |||
| data.put(KwBoxService.PREFIX_SYS_STATUS,record.getRegisterStatus()); | |||
| if (kwBox.getComKey() != null) | |||
| data.put(KwBoxService.PREFIX_COM_KEY,kwBox.getComKey()); | |||
| data.put(KwBoxService.PREFIX_COM_KEY,record.getComKey()); | |||
| if (kwBox.getConfig() != null) | |||
| data.put(KwBoxService.PREFIX_CONFIG,kwBox.getConfig()); | |||
| List<String> meters = kwBoxService.findMetersAddress(kwBox); | |||
| @@ -98,7 +103,24 @@ public class KwBoxV1Controller extends BaseController { | |||
| } | |||
| private ResultData cmdLogin(String imei, String ccid, Date deviceTime, Map<String,Object> paramMap) | |||
| private boolean checkSign(KwBox kwBox, Map<String,Object> paramMap, String sign) { | |||
| if (kwBox.getComKey() == null || sign == null) | |||
| return false; | |||
| HmacUtils hmacUtils = new HmacUtils(HmacAlgorithms.HMAC_SHA_1, kwBox.getComKey()); | |||
| String content = JSONObject.toJSON(paramMap).toString(); | |||
| String signCom = hmacUtils.hmacHex(content); | |||
| boolean res = signCom.equalsIgnoreCase(sign); | |||
| if (!res) { | |||
| logger.warn("SIGN check failed." + "content:"+content +"\n" + "signCom:" + signCom); | |||
| } | |||
| return res; | |||
| } | |||
| private ResultData cmdLogin(String imei, String ccid, Date deviceTime, Map<String,Object> paramMap, String sign) | |||
| { | |||
| KwBox kwBox = kwBoxService.findByImei(imei); | |||
| @@ -108,6 +130,9 @@ public class KwBoxV1Controller extends BaseController { | |||
| if (!kwBox.getRegisterStatus().equals(EnumBoxRegisterStatus.REGISTERED.getCode())) | |||
| return new ResultData(ErrorCode.DEVICE_NOT_FOUND); | |||
| if (!checkSign(kwBox, paramMap, sign)) | |||
| return new ResultData(ErrorCode.DEVICE_SIGN_INVALID); | |||
| saveCmd(kwBox.getTenantId(),KwBoxService.CMD_LOGIN,imei,ccid,deviceTime,paramMap); | |||
| KwBox record = new KwBox(); | |||
| @@ -124,7 +149,7 @@ public class KwBoxV1Controller extends BaseController { | |||
| private ResultData cmdHb(String imei, String ccid, Date deviceTime, Map<String,Object> paramMap) | |||
| private ResultData cmdHb(String imei, String ccid, Date deviceTime, Map<String,Object> paramMap, String sign) | |||
| { | |||
| KwBox kwBox = kwBoxService.findByImei(imei); | |||
| if (kwBox == null) | |||
| @@ -133,6 +158,9 @@ public class KwBoxV1Controller extends BaseController { | |||
| if (!kwBox.getRegisterStatus().equals(EnumBoxRegisterStatus.REGISTERED.getCode())) | |||
| return new ResultData(ErrorCode.DEVICE_NOT_FOUND); | |||
| if (!checkSign(kwBox, paramMap, sign)) | |||
| return new ResultData(ErrorCode.DEVICE_SIGN_INVALID); | |||
| saveCmd(kwBox.getTenantId(),KwBoxService.CMD_HEARTBEAT,imei,ccid,deviceTime,paramMap); | |||
| KwBox record = new KwBox(); | |||
| @@ -178,7 +206,8 @@ public class KwBoxV1Controller extends BaseController { | |||
| @ApiOperation("开物盒子V1") | |||
| @PostMapping("command") | |||
| public Result command(@RequestBody Map<String,Object> paramMap) { | |||
| public Result command(@RequestBody Map<String,Object> paramMap,@RequestParam String sign) { | |||
| String cmd = (String)paramMap.get(KwBoxService.PREFIX_CMD); | |||
| if (StringUtil.isNullOrEmpty(cmd)) | |||
| @@ -210,9 +239,9 @@ public class KwBoxV1Controller extends BaseController { | |||
| case KwBoxService.CMD_REGISTER: | |||
| return cmdRegist(imei,ccid,deviceTime,paramMap); | |||
| case KwBoxService.CMD_LOGIN: | |||
| return cmdLogin(imei,ccid,deviceTime,paramMap); | |||
| return cmdLogin(imei,ccid,deviceTime,paramMap,sign); | |||
| case KwBoxService.CMD_HEARTBEAT: | |||
| return cmdHb(imei,ccid,deviceTime,paramMap); | |||
| return cmdHb(imei,ccid,deviceTime,paramMap,sign); | |||
| } | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| @@ -110,7 +110,7 @@ public enum ErrorCode{ | |||
| COUPON_VALID_DATE_ERR(2035, "券有效期设置错误"), | |||
| COUPON_STOCK_VALID_DATE_SETTING_ERR(2036, "券库存有效期未修改"), | |||
| COUPON_STOCK_DATE_NO_CAR(2037, "券库存不支持停车券"), | |||
| COUPON_ONLY_FOR_NEW_MEMBER(2038, "您已参加过新会员活动"), | |||
| COUPON_SCORE_NOT_IN_RANGE(2038, "您的成长值/等级与要求不符"), | |||
| COUPON_STOCK_NO_EQUAL_ERR(2039, "券库存设置要保证同增同减"), | |||
| COUPON_STOCK_ENDTIME_ERR(2043, "抱歉,有效期截止时间只能增加不能减少!"), | |||
| @@ -118,6 +118,9 @@ public enum ErrorCode{ | |||
| PUSH_LIMIT_UP_TO_1DAYLIMIT(2040, "此用户一天内发券到达疲劳度限制"), | |||
| PUSH_LIMIT_UP_TO_COUPONLIMIT(2041, "此用户发此券到达疲劳度限制"), | |||
| PUSH_LIMIT_NOT_INRANG(2042, "不在疲劳度允许的时间段"), | |||
| COUPON_ONLY_FOR_NEW_MEMBER(2044, "您已经参加过新会员活动"), | |||
| COUPON_ALREADY_IN_NEW_MEMBER(2045, "您正在参加别的新会员活动"), | |||
| /** | |||
| * 车流 2040 | |||
| */ | |||
| @@ -409,6 +412,7 @@ public enum ErrorCode{ | |||
| DEVICE_QRCODE_GET_FAILED(26002, "微信二维码生成失败,请重试"), | |||
| DEVICE_REACHED_MAX_NUMBER(26003, "设备已经达到最大数量"), | |||
| DEVICE_HAS_BEEN_BOUND(26004, "设备已经绑定到其他商户"), | |||
| DEVICE_SIGN_INVALID(26005, "设备签名无效"), | |||
| /** | |||
| * 消息组件 | |||
| */ | |||
| @@ -57,23 +57,23 @@ public class WxCouponOrderBVo extends WxCouponOrder{ | |||
| @io.swagger.annotations.ApiModelProperty(value="c用户绑定的手机号",name="cUserPhone") | |||
| private String cUserPhone; | |||
| @Excel(name = "交易时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "8") | |||
| @Excel(name = "交易时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "9") | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate") | |||
| private Date createDate; | |||
| @Transient | |||
| @Excel(name = "面额(元)", width = 20, orderNum = "6") | |||
| @Excel(name = "面额(元)", width = 20, orderNum = "7") | |||
| private String priceStr; | |||
| @Transient | |||
| @Excel(name = "交易价格(元)", width = 20, orderNum = "5") | |||
| @Excel(name = "交易价格(元)", width = 20, orderNum = "6") | |||
| private String salePriceStr; | |||
| @Excel(name = "状态", width = 20, replace = {"待使用_0", "已核销_1", "已过期_2", "已退款_3"}, orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态:0,待使用 1,已核销 2,已过期 3,已作废 ", name = "couponOrderStatus") | |||
| private Integer couponOrderStatus; | |||
| @Excel(name = "核销/过期/退款时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "9") | |||
| @Excel(name = "核销/过期/退款时间", width = 20, exportFormat = "yyyy-MM-dd HH:mm:ss", orderNum = "10") | |||
| @io.swagger.annotations.ApiModelProperty(value = "", name = "updateDate") | |||
| private Date updateDate; | |||
| @@ -101,7 +101,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{ | |||
| return new BigDecimal(subsidyNum == null ? 0 : subsidyNum).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_EVEN).toPlainString(); | |||
| } | |||
| @Excel(name = "补贴额(元)", width = 50, orderNum = "7") | |||
| @Excel(name = "补贴额(元)", width = 50, orderNum = "8") | |||
| @io.swagger.annotations.ApiModelProperty(value = "补贴额", name = "subsidyNumStr") | |||
| private String subsidyNumStr; | |||
| @@ -112,11 +112,11 @@ 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; | |||
| @Excel(name = "商铺号", width = 50, orderNum = "4") | |||
| @Excel(name = "商铺号", width = 50, orderNum = "5") | |||
| @Transient | |||
| private String shopNumber; | |||
| @@ -146,7 +146,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{ | |||
| @Transient | |||
| private Integer couponType; | |||
| @Excel(name = "核销商户", width = 50, orderNum = "16") | |||
| @Excel(name = "核销商户", width = 50, orderNum = "4") | |||
| @Transient | |||
| private String verifyMerchantName; | |||
| @@ -14,6 +14,7 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| List<WxOrder> findList(WxOrder wxOrder); | |||
| Integer countList(WxOrder wxOrder); | |||
| int countCouponConditionType1(WxOrder wxOrder); | |||
| List<WxOrder> findListOfUnpaidOrderByDate(Map dateMap); | |||
| @@ -166,6 +166,7 @@ public interface WxOrderService { | |||
| */ | |||
| WxOrder getUnPaidOrder(WxCUser cUser, WxCoupon coupon); | |||
| int countCouponConditionType1(WxCUser user); | |||
| /** | |||
| * 订单处理 | |||
| * 1. 检查coupon是否免费 | |||
| @@ -248,6 +248,36 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| return null; | |||
| } | |||
| /** | |||
| * 用户正在参加的新手活动 | |||
| * @param user | |||
| * @return | |||
| */ | |||
| public int countCouponConditionType1(WxCUser user) { | |||
| // + Order 待支付 | |||
| try { | |||
| WxOrder orderQ = new WxOrder(); | |||
| orderQ.setTenantId(user.getTenantId()); | |||
| orderQ.setType(EnumOrderType.COUPON.getCode()); | |||
| orderQ.setCUserId(user.getId()); | |||
| List<Integer> statusS = new ArrayList<>(); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESSING.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_PRESS_COMPLETE.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode()); | |||
| statusS.add(EnumOrderStatus.ORDER_STATUS_COOPERATING_UNPAID.getCode()); | |||
| orderQ.setStatusS(statusS); | |||
| return wxOrderMapper.countCouponConditionType1(orderQ); | |||
| } catch (Exception e) { | |||
| logger.error("用户正在参加的新手活动, userId: " + user.getId() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| } | |||
| /** | |||
| * 用户购买的券包数量- 待使用的券 | |||
| * @param user | |||
| @@ -24,7 +24,13 @@ | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where cc.status = 0 | |||
| where 1=1 | |||
| <if test="null != status "> | |||
| and cc.status = #{status} | |||
| </if> | |||
| <if test="null == status "> | |||
| and cc.status = 0 | |||
| </if> | |||
| <if test=" null != id "> | |||
| and cc.`id` = #{id} | |||
| @@ -474,7 +474,7 @@ | |||
| <if test=" null != business "> | |||
| and c.business = #{business} | |||
| </if> | |||
| <if test=" null != verifyMerchantName ''!= verifyMerchantName "> | |||
| <if test=" null != verifyMerchantName and ''!= verifyMerchantName "> | |||
| and bu.verify_merchant_name = #{verifyMerchantName} | |||
| </if> | |||
| @@ -136,6 +136,32 @@ | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="countCouponConditionType1" parameterType="com.iformall.domain.po.WxOrder" resultType="java.lang.Integer"> | |||
| select count(*) from wx_order o,wx_coupon c | |||
| where o.product_id = c.id | |||
| and c.conditions is not null | |||
| and JSON_EXTRACT(c.conditions, '$.type') = 1 | |||
| <if test=" null != cUserId "> | |||
| and o.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != tenantId "> | |||
| and o.tenant_id = #{tenantId} | |||
| </if> | |||
| <if test=" null != type "> | |||
| and o.type = #{type} | |||
| </if> | |||
| <if test=" null != statusS "> | |||
| and o.order_status in | |||
| <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")"> | |||
| #{sItem} | |||
| </foreach> | |||
| </if> | |||
| </select> | |||
| <select id="findListOfUnpaidOrderByDate" parameterType="map" resultMap="BaseResultMap"> | |||
| select | |||