diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index e90bb844..dab67849 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -451,6 +451,7 @@ public class HighOrderController { } highOrder.setMerchId(request.getHeader("mchId")); + highOrder.setWhetherRebate(false); highOrder.setTotalPrice(totalPrice); highOrder.setPayablePrice(totalActualPrice); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java index e29f8ce7..5c9fffb6 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCommonController.java @@ -55,6 +55,8 @@ public class HighUserCommonController { @ApiOperation(value = "登录接口【用户不存在会自动注册】") public ResponseData login(@RequestParam(value = "phone", required = true) String phone, @RequestParam(value = "code", required = true) String code, + @RequestParam(value = "popularizeUserId", required = false) Long popularizeUserId, + @RequestParam(value = "regionId", required = false) String regionId, HttpServletRequest request, HttpServletResponse response) { try { @@ -80,7 +82,8 @@ public class HighUserCommonController { // 1:需要填写用户信息 // 2:需要填写手机号 user.setInfoCompleteStatus(1); - highUserService.insertUser(user); + + highUserService.insertUser(user , popularizeUserId , regionId); } HighUserModel highUserModel = new HighUserModel(); @@ -99,6 +102,8 @@ public class HighUserCommonController { @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData unionPhoneLogin(@RequestParam(value = "code", required = true) String code, + @RequestParam(value = "popularizeUserId", required = false) Long popularizeUserId, + @RequestParam(value = "regionId", required = false) String regionId, HttpServletRequest request, HttpServletResponse response) { try { @@ -133,7 +138,7 @@ public class HighUserCommonController { // 1:需要填写用户信息 // 2:需要填写手机号 user.setInfoCompleteStatus(1); - highUserService.insertUser(user); + highUserService.insertUser(user , popularizeUserId , regionId); } else { user.setUnionOpenId(token.getJSONObject("params").getString("openId")); user.setUnionUnionId(token.getJSONObject("params").getString("unionId")); diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index bfa8bf3e..4f1a7e02 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -54,9 +54,6 @@ public class WechatController { @Resource private HighUserService highUserService; - @Resource - private HighUserPayPasswordService highUserPayPasswordService; - @Resource private RedisUtil redisUtil; @@ -89,6 +86,8 @@ public class WechatController { public ResponseData loginByPhone(@RequestParam(value = "encryptedData", required = true) String encryptedData, @RequestParam(value = "iv", required = true) String iv, @RequestParam(value = "openId", required = true) String openId, + @RequestParam(value = "popularizeUserId", required = false) Long popularizeUserId, + @RequestParam(value = "regionId", required = false) String regionId, HttpServletRequest request, HttpServletResponse response) { try { log.error("origin encryptedData:" + encryptedData + ";iv:" + iv); @@ -130,7 +129,7 @@ public class WechatController { // 1:需要填写用户信息 // 2:需要填写手机号 user.setInfoCompleteStatus(1); - highUserService.insertUser(user); + highUserService.insertUser(user , popularizeUserId , regionId); } else { if (session.getOpenid() == null) { user.setOpenId(session.getOpenid()); @@ -248,6 +247,8 @@ public class WechatController { @ApiOperation(value = "根据手机号码登陆") public ResponseData loginByTel(@RequestParam(value = "phone", required = true) String phone, @RequestParam(value = "code", required = true) String code, + @RequestParam(value = "popularizeUserId", required = false) Long popularizeUserId, + @RequestParam(value = "regionId", required = false) String regionId, HttpServletRequest request, HttpServletResponse response) { try { @@ -267,7 +268,7 @@ public class WechatController { // 1:需要填写用户信息 // 2:需要填写手机号 user.setInfoCompleteStatus(1); - highUserService.insertUser(user); + highUserService.insertUser(user , popularizeUserId , regionId); } // 获取手机号验证码 diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java index 0c936def..d86bdc37 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapper.java @@ -58,9 +58,9 @@ public interface HighOrderMapper extends HighOrderMapperExt { "profit_sharing_ratio, account_merchant_num, ", "product_type, print_status, ", "print_num, whether_check, ", - "region_id, company_id, ", - "merch_id, ext_1, ext_2, ", - "ext_3)", + "whether_rebate, region_id, ", + "company_id, merch_id, ", + "ext_1, ext_2, ext_3)", "values (#{orderNo,jdbcType=VARCHAR}, #{memDiscountId,jdbcType=BIGINT}, ", "#{memDiscountName,jdbcType=VARCHAR}, #{memId,jdbcType=BIGINT}, ", "#{memName,jdbcType=VARCHAR}, #{memPhone,jdbcType=VARCHAR}, ", @@ -80,9 +80,9 @@ public interface HighOrderMapper extends HighOrderMapperExt { "#{profitSharingRatio,jdbcType=DECIMAL}, #{accountMerchantNum,jdbcType=VARCHAR}, ", "#{productType,jdbcType=INTEGER}, #{printStatus,jdbcType=BIT}, ", "#{printNum,jdbcType=INTEGER}, #{whetherCheck,jdbcType=BIT}, ", - "#{regionId,jdbcType=VARCHAR}, #{companyId,jdbcType=BIGINT}, ", - "#{merchId,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ", - "#{ext3,jdbcType=VARCHAR})" + "#{whetherRebate,jdbcType=BIT}, #{regionId,jdbcType=VARCHAR}, ", + "#{companyId,jdbcType=BIGINT}, #{merchId,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighOrder record); @@ -132,6 +132,7 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="print_status", property="printStatus", jdbcType=JdbcType.BIT), @Result(column="print_num", property="printNum", jdbcType=JdbcType.INTEGER), @Result(column="whether_check", property="whetherCheck", jdbcType=JdbcType.BIT), + @Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT), @Result(column="region_id", property="regionId", jdbcType=JdbcType.VARCHAR), @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="merch_id", property="merchId", jdbcType=JdbcType.VARCHAR), @@ -149,8 +150,8 @@ public interface HighOrderMapper extends HighOrderMapperExt { "total_price, create_time, pay_time, cancel_time, cancel_remarks, finish_time, ", "remarks, refund_no, refund_time, refund_price, refund_content, refusal_refund_content, ", "Identification_code, profit_sharing_status, profit_sharing_ratio, account_merchant_num, ", - "product_type, print_status, print_num, whether_check, region_id, company_id, ", - "merch_id, ext_1, ext_2, ext_3", + "product_type, print_status, print_num, whether_check, whether_rebate, region_id, ", + "company_id, merch_id, ext_1, ext_2, ext_3", "from high_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -194,6 +195,7 @@ public interface HighOrderMapper extends HighOrderMapperExt { @Result(column="print_status", property="printStatus", jdbcType=JdbcType.BIT), @Result(column="print_num", property="printNum", jdbcType=JdbcType.INTEGER), @Result(column="whether_check", property="whetherCheck", jdbcType=JdbcType.BIT), + @Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT), @Result(column="region_id", property="regionId", jdbcType=JdbcType.VARCHAR), @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="merch_id", property="merchId", jdbcType=JdbcType.VARCHAR), @@ -252,6 +254,7 @@ public interface HighOrderMapper extends HighOrderMapperExt { "print_status = #{printStatus,jdbcType=BIT},", "print_num = #{printNum,jdbcType=INTEGER},", "whether_check = #{whetherCheck,jdbcType=BIT},", + "whether_rebate = #{whetherRebate,jdbcType=BIT},", "region_id = #{regionId,jdbcType=VARCHAR},", "company_id = #{companyId,jdbcType=BIGINT},", "merch_id = #{merchId,jdbcType=VARCHAR},", @@ -261,4 +264,4 @@ public interface HighOrderMapper extends HighOrderMapperExt { "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(HighOrder record); -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index ac3efd3b..1854ffa4 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1250,7 +1250,7 @@ public interface HighOrderMapperExt { }) List getSelfOilStationOrderList(@Param("goodsId") String goodsId); - @Select("select * from high_order where order_status = 3 and pay_type != 3 and pay_real_price > 0 ") + @Select("select * from high_order where order_status = 3 and pay_type != 3 and pay_real_price > 0 and whether_rebate = false ") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), diff --git a/hai-service/src/main/java/com/hai/entity/HighOrder.java b/hai-service/src/main/java/com/hai/entity/HighOrder.java index d08cbfd0..7fc2c1f5 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrder.java @@ -210,6 +210,11 @@ public class HighOrder implements Serializable { */ private Boolean whetherCheck; + /** + * 是否返利 + */ + private Boolean whetherRebate; + /** * 区域编码 */ @@ -615,6 +620,14 @@ public class HighOrder implements Serializable { this.whetherCheck = whetherCheck; } + public Boolean getWhetherRebate() { + return whetherRebate; + } + + public void setWhetherRebate(Boolean whetherRebate) { + this.whetherRebate = whetherRebate; + } + public String getRegionId() { return regionId; } @@ -714,6 +727,7 @@ public class HighOrder implements Serializable { && (this.getPrintStatus() == null ? other.getPrintStatus() == null : this.getPrintStatus().equals(other.getPrintStatus())) && (this.getPrintNum() == null ? other.getPrintNum() == null : this.getPrintNum().equals(other.getPrintNum())) && (this.getWhetherCheck() == null ? other.getWhetherCheck() == null : this.getWhetherCheck().equals(other.getWhetherCheck())) + && (this.getWhetherRebate() == null ? other.getWhetherRebate() == null : this.getWhetherRebate().equals(other.getWhetherRebate())) && (this.getRegionId() == null ? other.getRegionId() == null : this.getRegionId().equals(other.getRegionId())) && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) && (this.getMerchId() == null ? other.getMerchId() == null : this.getMerchId().equals(other.getMerchId())) @@ -765,6 +779,7 @@ public class HighOrder implements Serializable { result = prime * result + ((getPrintStatus() == null) ? 0 : getPrintStatus().hashCode()); result = prime * result + ((getPrintNum() == null) ? 0 : getPrintNum().hashCode()); result = prime * result + ((getWhetherCheck() == null) ? 0 : getWhetherCheck().hashCode()); + result = prime * result + ((getWhetherRebate() == null) ? 0 : getWhetherRebate().hashCode()); result = prime * result + ((getRegionId() == null) ? 0 : getRegionId().hashCode()); result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode()); result = prime * result + ((getMerchId() == null) ? 0 : getMerchId().hashCode()); @@ -819,6 +834,7 @@ public class HighOrder implements Serializable { sb.append(", printStatus=").append(printStatus); sb.append(", printNum=").append(printNum); sb.append(", whetherCheck=").append(whetherCheck); + sb.append(", whetherRebate=").append(whetherRebate); sb.append(", regionId=").append(regionId); sb.append(", companyId=").append(companyId); sb.append(", merchId=").append(merchId); diff --git a/hai-service/src/main/java/com/hai/service/BsDistributionUserRelService.java b/hai-service/src/main/java/com/hai/service/BsDistributionUserRelService.java index bae156b7..8d5fdd75 100644 --- a/hai-service/src/main/java/com/hai/service/BsDistributionUserRelService.java +++ b/hai-service/src/main/java/com/hai/service/BsDistributionUserRelService.java @@ -23,7 +23,7 @@ public interface BsDistributionUserRelService { * @Param [java.lang.Long, java.lang.Long] * @return void */ - void insertDistributionRebate(Long userId , String userName, Long popularizeUserId); + void insertDistributionRebate(Long userId , Long popularizeUserId , String regionId); /** * @Author Sum1Dream diff --git a/hai-service/src/main/java/com/hai/service/HighUserService.java b/hai-service/src/main/java/com/hai/service/HighUserService.java index 14928723..46862901 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserService.java @@ -99,7 +99,7 @@ public interface HighUserService { * @param: [highUser] 用户信息 * @return: com.hai.entity.HighUser */ - void insertUser(HighUser highUser); + void insertUser(HighUser highUser , Long popularizeUserId , String regionId); /** * @Author 胡锐 diff --git a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java index bccc9d63..5b7a3a0a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsDistributionUserRelServiceImpl.java @@ -1,11 +1,8 @@ package com.hai.service.impl; -import com.hai.dao.BsDistributionRebateMapper; import com.hai.dao.BsDistributionUserRelMapper; -import com.hai.entity.BsDistributionRebate; -import com.hai.entity.BsDistributionUserRel; -import com.hai.entity.BsDistributionUserRelExample; -import com.hai.service.BsDistributionUserRelService; +import com.hai.entity.*; +import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; @@ -21,8 +18,23 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe @Resource private BsDistributionUserRelMapper bsDistributionUserRelMapper; + @Resource + private HighDiscountPackageService highDiscountPackageService; + + @Resource + private HighUserService highUserService; + + @Resource + private BsCompanyService bsCompanyService; + + @Resource + private CommonService commonService; + + @Override - public void insertDistributionRebate(Long userId, String userName , Long popularizeUserId) { + public void insertDistributionRebate(Long userId, Long popularizeUserId , String regionId) { + + HighUser user = highUserService.findByUserId(userId); // 定义分销关联关系 BsDistributionUserRel distributionUserRel = new BsDistributionUserRel(); @@ -34,7 +46,7 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe BsDistributionUserRel popularizeUser = findDistributionUserRel(map); distributionUserRel.setUserId(userId); - distributionUserRel.setUserName(userName); + distributionUserRel.setUserName(user.getName()); distributionUserRel.setAgentId(popularizeUser.getAgentId()); distributionUserRel.setAgentName(popularizeUser.getAgentName()); distributionUserRel.setPopularizeUserId(popularizeUserId); @@ -45,6 +57,34 @@ public class BsDistributionUserRelServiceImpl implements BsDistributionUserRelSe bsDistributionUserRelMapper.insert(distributionUserRel); + new Thread(() -> { + + try { + + SecRegion region = commonService.getParentByRegion(Long.valueOf(regionId)); + BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); + + // 查询注册有礼优惠券包 + HighDiscountPackage discountPackage = highDiscountPackageService.getCallExclusive(3 , bsCompany.getId().intValue()); + Map freeMap = new HashMap<>(); + freeMap.put("discountPackageId", discountPackage.getId()); + freeMap.put("userId", userId); + freeMap.put("userPhone", user.getPhone()); + highDiscountPackageService.freeUserDiscountPackage(freeMap); + + // 查询推广有礼优惠券包 + HighDiscountPackage promoteDiscountPackage = highDiscountPackageService.getCallExclusive(4 , bsCompany.getId().intValue()); + Map freeMap1 = new HashMap<>(); + freeMap1.put("discountPackageId", promoteDiscountPackage.getId()); + freeMap1.put("userId", userId); + freeMap1.put("userPhone", user.getPhone()); + highDiscountPackageService.freeUserDiscountPackage(freeMap1); + } catch (Exception e) { + e.printStackTrace(); + } + + }).start(); + } @Override diff --git a/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java index dc153fe4..decf564a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsIntegralRebateServiceImpl.java @@ -109,6 +109,10 @@ public class BsIntegralRebateServiceImpl implements BsIntegralRebateService { HighOrder order = highOrderService.getOrderById(object.getLong("orderId")); + order.setWhetherRebate(true); + + highOrderService.updateOrder(order); + highUserService.goldHandle(object.getLong("userId"), integralNum.intValue(), 1, 4, object.getLong("orderId") , object.getString("remark") + integralNum); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java index a0ce3fdd..b8e714dc 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java @@ -402,7 +402,7 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic user.setGold(0); user.setStatus(1); user.setInfoCompleteStatus(1); // 用户信息完整状态 0:完整 1:需要填写用户信息 2:需要填写手机号 - highUserService.insertUser(user); + highUserService.insertUser(user , null , null); // 赠送卷包 Map freeMap = new HashMap<>(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index fb45eb09..140787f0 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -61,6 +61,9 @@ public class HighUserServiceImpl implements HighUserService { @Resource private HighOilCardService oilCardService; + @Resource + private BsDistributionUserRelService distributionUserRelService; + @Override public List getListUser(Map map) { HighUserExample example = new HighUserExample(); @@ -212,7 +215,7 @@ public class HighUserServiceImpl implements HighUserService { @Override @Transactional(propagation= Propagation.REQUIRES_NEW) - public void insertUser(HighUser highUser) { + public void insertUser(HighUser highUser , Long popularizeUserId , String regionId) { highUserMapper.insert(highUser); if (highUser.getPhone() != null) { @@ -221,6 +224,11 @@ public class HighUserServiceImpl implements HighUserService { highUserCardService.bindCard(UserCardType.type2.getType(), oilCard.getCardNo(), highUser.getId()); } } + + new Thread(()-> { + // 绑定推广关联关系 + distributionUserRelService.insertDistributionRebate(highUser.getId() , popularizeUserId , regionId); + }); } @Override