提交赠券功能

dev-discount
袁野 3 years ago
parent c96fbdf826
commit e7c770b92f
  1. 1
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java
  2. 249
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java
  3. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  4. 15
      hai-bweb/src/main/java/com/bweb/controller/HighUserController.java
  5. 22
      hai-cweb/src/main/java/com/cweb/controller/HighUserController.java
  6. 28
      hai-service/src/main/java/com/hai/dao/HighDiscountPackageRecordMapperExt.java
  7. 1
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  8. 7
      hai-service/src/main/java/com/hai/service/HighDiscountAgentRelService.java
  9. 22
      hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java
  10. 26
      hai-service/src/main/java/com/hai/service/HltUnionCardVipService.java
  11. 1
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java
  12. 8
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java
  13. 7
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageDetailsServiceImpl.java
  14. 50
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
  15. 3
      hai-service/src/main/java/com/hai/service/impl/HighDiscountServiceImpl.java
  16. 185
      hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java

@ -208,6 +208,7 @@ public class HighDiscountController {
map.put("useScope", useScope);
map.put("discountName", discountName);
map.put("discountType", discountType);
map.put("useScope", useScope);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highDiscountService.getDiscount(map)));

@ -18,7 +18,6 @@ import com.hai.service.HighDiscountPackageService;
import com.hai.service.HighDiscountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -28,7 +27,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -89,6 +87,38 @@ public class HighDiscountPackageController {
}
}
@RequestMapping(value = "/getDiscountPackageRecordList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取优惠券包记录列表")
public ResponseData getDiscountPackageRecordList(@RequestParam(name = "usingAttribution", required = false) Integer usingAttribution,
@RequestParam(name = "discountPackageTitle", required = false) String discountPackageTitle,
@RequestParam(name = "recordNo", required = false) String recordNo,
@RequestParam(name = "phone", required = false) String phone,
@RequestParam(name = "salesType", required = false) Integer salesType,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
Map<String,Object> map = new HashMap<>();
map.put("companyId", userInfoModel.getBsCompany().getId());
map.put("usingAttribution", usingAttribution);
map.put("discountPackageTitle" , discountPackageTitle);
map.put("recordNo" , recordNo);
map.put("phone" , phone);
map.put("salesType" , salesType);
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highDiscountPackageService.getDiscountPackageRecordList(map)));
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/insertCouponPackageInfo", method = RequestMethod.POST)
@ResponseBody
@ -101,7 +131,6 @@ public class HighDiscountPackageController {
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (StringUtils.isBlank(highDiscountPackage.getTitle())
|| highDiscountPackage.getUsingAttribution() == null
|| highDiscountPackage.getSalesType() == null
|| StringUtils.isBlank(highDiscountPackage.getBannerImg())
|| StringUtils.isBlank(highDiscountPackage.getListImg())
@ -125,6 +154,11 @@ public class HighDiscountPackageController {
}
}
if (highDiscountPackageService.getCallExclusive(highDiscountPackage.getUsingAttribution() , userInfoModel.getBsCompany().getId().intValue()) != null) {
log.error("highCouponPackage -> insertCouponPackageInfo() error!","当前优惠券已存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前优惠券已存在");
}
highDiscountPackage.setCompanyId(userInfoModel.getBsCompany().getId().intValue());
highDiscountPackage.setStatus(3);
highDiscountPackage.setCreatedTime(new Date());
@ -137,7 +171,7 @@ public class HighDiscountPackageController {
return ResponseMsgUtil.success(highDiscountPackage);
} catch (Exception e) {
log.error("HighAgentController --> insertAgent() error!", e);
log.error("HighAgentController --> insertCouponPackageInfo() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@ -153,50 +187,64 @@ public class HighDiscountPackageController {
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (StringUtils.isBlank(highDiscountPackage.getTitle())
|| highDiscountPackage.getUsingAttribution() == null
|| highDiscountPackage.getSalesType() == null
|| highDiscountPackage.getId() == null
|| highDiscountPackage.getEffectiveTiem() == null
|| highDiscountPackage.getPurchaseNum() == null
|| highDiscountPackage.getPrice() == null
|| StringUtils.isBlank(highDiscountPackage.getBannerImg())
|| StringUtils.isBlank(highDiscountPackage.getListImg())
|| StringUtils.isBlank(highDiscountPackage.getDetailsImg())
) {
log.error("HighAgentController -> insertAgent() error!","参数错误");
log.error("HighAgentController -> updateCouponPackageInfo() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
log.error("highCouponPackage -> updateCouponPackageInfo() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackages = highDiscountPackageService.findDiscountPackageById(highDiscountPackage.getId());
if (highDiscountPackages == null || highDiscountPackage.getStatus() == 1) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
if (highDiscountPackages == null || highDiscountPackages.getStatus() == 1) {
log.error("highCouponPackage -> updateCouponPackageInfo() error!","状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
highDiscountPackages.setStatus(3);
highDiscountPackages.setUpdatedTime(new Date());
highDiscountPackages.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
if (highDiscountPackage.getSalesType() == 1) {
if (highDiscountPackage.getPurchaseNum() == null
|| highDiscountPackage.getPrice() == null
) {
log.error("HighAgentController -> updateCouponPackageInfo() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
}
highDiscountPackageService.insertDiscountPackage(highDiscountPackage);
if (highDiscountPackageService.getCallExclusive(highDiscountPackage.getUsingAttribution() , userInfoModel.getBsCompany().getId().intValue()) != null) {
log.error("highCouponPackage -> updateCouponPackageInfo() error!","专属优惠券已存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "专属优惠券已存在");
}
highDiscountPackage.setStatus(3);
highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackage.setCompanyId(highDiscountPackages.getCompanyId());
highDiscountPackage.setCreatedUserId(highDiscountPackages.getCreatedUserId());
highDiscountPackage.setCreatedTime(highDiscountPackages.getCreatedTime());
highDiscountPackageService.updateDiscountPackage(highDiscountPackage);
return ResponseMsgUtil.success(highDiscountPackage);
} catch (Exception e) {
log.error("HighAgentController --> insertAgent() error!", e);
log.error("HighAgentController --> updateCouponPackageInfo() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/highCouponPackageRule", method = RequestMethod.POST)
@RequestMapping(value = "/insertCouponPackageRule", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增优惠券包规则信息")
public ResponseData highCouponPackageRule(@RequestBody HighDiscountPackageDetails highDiscountPackageDetails, HttpServletRequest request) {
public ResponseData insertCouponPackageRule(@RequestBody HighDiscountPackageDetails highDiscountPackageDetails, HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
@ -206,22 +254,31 @@ public class HighDiscountPackageController {
|| highDiscountPackageDetails.getDiscountId() == null
|| highDiscountPackageDetails.getNum() == null
) {
log.error("HighAgentController -> insertAgent() error!","参数错误");
log.error("HighAgentController -> insertCouponPackageRule() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
log.error("highCouponPackage -> insertCouponPackageRule() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscount discount = highDiscountService.getDiscountById(highDiscountPackageDetails.getDiscountId().longValue());
if (discount == null || highDiscountPackageService.findDiscountPackageById(highDiscountPackageDetails.getDiscountPackageId()) == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","优惠券 或者 优惠券包不存在");
log.error("highCouponPackage -> insertCouponPackageRule() error!","优惠券 或者 优惠券包不存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "优惠券 或者 优惠券包不存在");
}
Map<String , Object> map = new HashMap<>();
map.put("discountPackageId", highDiscountPackageDetails.getDiscountPackageId());
map.put("discountId" , highDiscountPackageDetails.getDiscountId());
if (highDiscountPackageDetailsService.getDiscountPackageDetailsList(map).size() > 0) {
log.error("highCouponPackage -> insertCouponPackageRule() error!","当前优惠券已存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前优惠券已存在");
}
highDiscountPackageDetails.setStatus(1);
highDiscountPackageDetails.setDiscountName(discount.getDiscountName());
highDiscountPackageDetails.setCreatedTime(new Date());
@ -231,7 +288,7 @@ public class HighDiscountPackageController {
highDiscountPackageDetailsService.insertDiscountPackageDetails(highDiscountPackageDetails);
return ResponseMsgUtil.success(null);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("HighAgentController --> insertAgent() error!", e);
@ -242,7 +299,7 @@ public class HighDiscountPackageController {
@RequestMapping(value = "/getDiscountPackageRuleList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取优惠券包规则列表")
public ResponseData getDiscountPackageRuleList(@RequestParam(name = "discountPackageId", required = true) Integer discountPackageId,
public ResponseData getDiscountPackageRuleList(@RequestParam(name = "id", required = true) Integer id,
HttpServletRequest request) {
try {
@ -257,7 +314,7 @@ public class HighDiscountPackageController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
map.put("discountPackageId", discountPackageId);
map.put("discountPackageId", id);
return ResponseMsgUtil.success(highDiscountPackageDetailsService.getDiscountPackageDetailsList(map));
@ -273,8 +330,6 @@ public class HighDiscountPackageController {
public ResponseData deleteDiscountPackageRule(@RequestBody JSONObject object, HttpServletRequest request) {
try {
Map<String,Object> map = new HashMap<>();
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
@ -305,4 +360,144 @@ public class HighDiscountPackageController {
}
}
@RequestMapping(value = "/deleteDiscountPackage", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除优惠券包")
public ResponseData deleteDiscountPackage(@RequestBody JSONObject object, HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
highDiscountPackage.setStatus(4);
highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackageService.updateDiscountPackage(highDiscountPackage);
return ResponseMsgUtil.success("删除成功");
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "upDiscountPackage", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "上架优惠券包")
public ResponseData upDiscountPackage(@RequestBody JSONObject object, HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
if (highDiscountPackage == null || highDiscountPackage.getStatus() == 1 ) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
highDiscountPackage.setStatus(1);
highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackageService.updateDiscountPackage(highDiscountPackage);
return ResponseMsgUtil.success("上架成功");
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "downDiscountPackage", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "下架优惠券包")
public ResponseData downDiscountPackage(@RequestBody JSONObject object, HttpServletRequest request) {
try {
//发布人员
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","该主角色没有权限");
throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, "");
}
HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(object.getInteger("discountId"));
if (highDiscountPackage == null) {
log.error("highCouponPackage -> highCouponPackageInfo() error!","状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
highDiscountPackage.setStatus(2);
highDiscountPackage.setUpdatedTime(new Date());
highDiscountPackage.setUpdatedUserId(userInfoModel.getSecUser().getId().intValue());
highDiscountPackageService.updateDiscountPackage(highDiscountPackage);
return ResponseMsgUtil.success("上架成功");
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDiscountPackageById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询")
public ResponseData getDiscountPackageById(@RequestParam(name = "id", required = true) Integer id) {
try {
return ResponseMsgUtil.success(highDiscountPackageService.findDiscountPackageById(id));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getDiscountPackageRuleById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询优惠券规则")
public ResponseData getDiscountPackageRuleById(@RequestParam(name = "id", required = true) Integer id) {
try {
Map<String,Object> map = new HashMap<>();
map.put("discountPackageId" , id);
return ResponseMsgUtil.success(highDiscountPackageDetailsService.getDiscountPackageDetailsList(map));
} catch (Exception e) {
log.error("HighDiscountController -> getDiscountById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1 +1 @@
package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET) @ResponseBody public ResponseData getBackendToken() { try { try { return ResponseMsgUtil.success(null); } catch (Exception e) { ); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } }
package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.model.ResultProfitSharing; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); log.error("HighOrderController --> getBackendToken() error!", e); @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ApiOperation(value = "获取访问令牌backendToken") @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) public ResponseData getBackendToken() { @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) try { @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) return ResponseMsgUtil.success(null); @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) } catch (Exception e) { @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) log.error("HighOrderController --> getBackendToken() error!", e); @ResponseBody @ResponseBody @ResponseBody @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ResponseBody @ResponseBody @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") @ResponseBody public ResponseData getBackendToken() { @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) try { @ResponseBody try { @ResponseBody return ResponseMsgUtil.success(null); @ResponseBody } catch (Exception e) { } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } }

@ -1,11 +1,13 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.entity.HighUser;
import com.hai.model.ResponseData;
import com.hai.service.HighUserService;
@ -149,4 +151,17 @@ public class HighUserController {
}
}
@RequestMapping(value = "/TCheckEMsgUnionCardVipRights", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "请求会员体系")
public ResponseData TCheckEMsgUnionCardVipRights(@RequestParam(name = "phone", required = true) String phone) {
try {
JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone);
return ResponseMsgUtil.success(consumptionRecord);
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -47,16 +47,10 @@ public class HighUserController {
private HighUserService highUserService;
@Resource
private HighUserCouponService highUserCouponService;
@Resource
private HighUserCardService highUserCardService;
@Resource
private HighOrderService highOrderService;
private HighUserPayPasswordService highUserPayPasswordService;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
private HltUnionCardVipService hltUnionCardVipService;
@Resource
private RedisUtil redisUtil;
@ -241,5 +235,17 @@ public class HighUserController {
}
}
@RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "请求会员体系")
public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) {
try {
return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId));
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,7 +1,33 @@
package com.hai.dao;
import com.hai.entity.HighDiscountPackage;
import com.hai.entity.HighDiscountPackageRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* mapper扩展类
*/
public interface HighDiscountPackageRecordMapperExt {
}
@Select(
" SELECT *" +
" FROM high_discount_package_record" +
" WHERE" +
" status = 1 " +
" AND sales_type = 2 " +
" AND user_id = #{userId} " +
" AND using_attribution = #{usingAttribution} " +
" AND DATE_FORMAT(created_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m'); "
)
/**
* 根据userId 查询当月是否赠送相关优惠券包
* @param userId 用户id
* @return
*/
List<HighDiscountPackageRecord> CheckCouponsMonth(@Param("userId") Long userId , @Param("usingAttribution") Integer usingAttribution);
}

@ -51,6 +51,7 @@ public interface HighDiscountAgentCodeService {
**/
List<HighDiscountAgentCode> getDiscountCodeByDiscountAgentId(Long discountAgentId);
/**
* @Author 胡锐
* @Description 根据id 查询二维码

@ -40,6 +40,13 @@ public interface HighDiscountAgentRelService {
**/
HighDiscountAgentRel getRelByDiscountAgent(Long discountId,Long agentId);
/**
* @Author 胡锐
* @Description 根据代理商id和卡券id查询
* @Date 2021/4/4 0:32
**/
List<HighDiscountAgentRel> getRelByDiscountId(Long discountId);
/**
* @Author 胡锐
* @Description 根据id查询

@ -2,6 +2,8 @@ package com.hai.service;
import com.hai.entity.HighDiscount;
import com.hai.entity.HighDiscountPackage;
import com.hai.entity.HighDiscountPackageRecord;
import io.swagger.models.auth.In;
import java.util.List;
import java.util.Map;
@ -35,6 +37,16 @@ public interface HighDiscountPackageService {
*/
HighDiscountPackage findDiscountPackageById(Integer id);
/**
* @Author Sum1Dream
* @name getCallExclusive.java
* @Description // 查询优惠券包专属
* @Date 4:02 下午 2021/11/30
* @Param [java.lang.Integer]
* @return com.hai.entity.HighDiscountPackage
*/
HighDiscountPackage getCallExclusive(Integer usingAttribution , Integer companyId);
/**
* @Author Sum1Dream
* @name insertCouponPackage.java
@ -55,5 +67,15 @@ public interface HighDiscountPackageService {
*/
void updateDiscountPackage(HighDiscountPackage highDiscountPackage);
/**
* @Author Sum1Dream
* @name getDiscountPackageRecordList.java
* @Description // 查询优惠券包赠送记录
* @Date 4:41 下午 2021/12/1
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.util.List<com.hai.entity.HighDiscountPackageRecord>
*/
List<HighDiscountPackageRecord> getDiscountPackageRecordList(Map<String , Object> map);
}

@ -0,0 +1,26 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
/**
* @serviceName HltUnionCardVipService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 汇联通会员体系
* @createTime 4:49 下午 2021/11/30
**/
public interface HltUnionCardVipService {
/**
* @Author Sum1Dream
* @name GetMembershipLevel.java
* @Description // 获取会员等级
* @Date 4:53 下午 2021/11/30
* @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject GetMembershipLevel(String phone , String regionId) throws Exception;
}

@ -101,6 +101,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe
return highDiscountAgentCodeMapper.selectByExample(example);
}
@Override
public HighDiscountAgentCode getCodeById(Long id) {
return highDiscountAgentCodeMapper.selectByPrimaryKey(id);

@ -96,6 +96,14 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
return null;
}
@Override
public List<HighDiscountAgentRel> getRelByDiscountId(Long discountId) {
HighDiscountAgentRelExample example = new HighDiscountAgentRelExample();
example.createCriteria().andDiscountIdEqualTo(discountId);
List<HighDiscountAgentRel> list = highDiscountAgentRelMapper.selectByExample(example);
return list;
}
@Override
public HighDiscountAgentRel getRelById(Long id) {
HighDiscountAgentRel rel = highDiscountAgentRelMapper.selectByPrimaryKey(id);

@ -31,8 +31,11 @@ public class HighDiscountPackageDetailsServiceImpl implements HighDiscountPackag
HighDiscountPackageDetailsExample example = new HighDiscountPackageDetailsExample();
HighDiscountPackageDetailsExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "DiscountPackageId") != null) {
criteria.andDiscountPackageIdEqualTo(MapUtils.getInteger(map, "DiscountPackageId"));
if (MapUtils.getInteger(map, "discountPackageId") != null) {
criteria.andDiscountPackageIdEqualTo(MapUtils.getInteger(map, "discountPackageId"));
}
if (MapUtils.getInteger(map, "discountId") != null) {
criteria.andDiscountIdEqualTo(MapUtils.getInteger(map, "discountId"));
}
criteria.andStatusEqualTo(1);

@ -1,8 +1,8 @@
package com.hai.service.impl;
import com.hai.dao.HighDiscountPackageMapper;
import com.hai.entity.HighDiscountPackage;
import com.hai.entity.HighDiscountPackageExample;
import com.hai.dao.HighDiscountPackageRecordMapper;
import com.hai.entity.*;
import com.hai.service.HighDiscountPackageService;
import com.hai.service.HighDiscountPackageService;
import org.apache.commons.collections4.MapUtils;
@ -25,6 +25,9 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
@Resource
private HighDiscountPackageMapper highDiscountPackageMapper;
@Resource
private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper;
@Override
public List<HighDiscountPackage> getDiscountPackageList(Map<String, Object> map) {
@ -50,7 +53,7 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
} else {
criteria.andStatusNotEqualTo(0);
criteria.andStatusNotEqualTo(4);
}
example.setOrderByClause("created_time desc");
@ -63,6 +66,14 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
return highDiscountPackageMapper.selectByPrimaryKey(id);
}
@Override
public HighDiscountPackage getCallExclusive(Integer usingAttribution , Integer companyId) {
HighDiscountPackageExample example = new HighDiscountPackageExample();
HighDiscountPackageExample.Criteria criteria = example.createCriteria();
criteria.andUsingAttributionEqualTo(usingAttribution).andStatusNotEqualTo(4).andCompanyIdEqualTo(companyId);;
return highDiscountPackageMapper.selectByExample(example).get(0);
}
@Override
public void insertDiscountPackage(HighDiscountPackage highDiscountPackage) {
highDiscountPackageMapper.insert(highDiscountPackage);
@ -72,4 +83,37 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic
public void updateDiscountPackage(HighDiscountPackage highDiscountPackage) {
highDiscountPackageMapper.updateByPrimaryKey(highDiscountPackage);
}
@Override
public List<HighDiscountPackageRecord> getDiscountPackageRecordList(Map<String, Object> map) {
HighDiscountPackageRecordExample example = new HighDiscountPackageRecordExample();
HighDiscountPackageRecordExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getInteger(map, "companyId"));
}
if (MapUtils.getInteger(map, "usingAttribution") != null) {
criteria.andUsingAttributionEqualTo(MapUtils.getInteger(map, "usingAttribution"));
}
if (MapUtils.getString(map, "discountPackageTitle") != null) {
criteria.andDiscountPackageTitleLike("%" + MapUtils.getString(map, "discountPackageTitle") + "%");
}
if (MapUtils.getString(map, "recordNo") != null) {
criteria.andRecordNoLike("%" + MapUtils.getString(map, "recordNo") + "%");
}
if (MapUtils.getInteger(map, "salesType") != null) {
criteria.andSalesTypeEqualTo(MapUtils.getInteger(map, "salesType"));
}
if (MapUtils.getString(map, "phone") != null) {
criteria.andExt1Like("%" + MapUtils.getString(map, "phone") + "%");
}
return highDiscountPackageRecordMapper.selectByExample(example);
}
}

@ -59,6 +59,9 @@ public class HighDiscountServiceImpl implements HighDiscountService {
if (MapUtils.getLong(map, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId"));
}
if (MapUtils.getLong(map, "useScope") != null) {
criteria.andUseScopeEqualTo(MapUtils.getInteger(map, "useScope"));
}
example.setOrderByClause("update_time desc");
return highDiscountMapper.selectByExample(example);

@ -0,0 +1,185 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.dao.HighDiscountPackageRecordMapper;
import com.hai.dao.HighDiscountUserRelMapper;
import com.hai.entity.*;
import com.hai.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
@Service("hltUnionCardVipService")
public class HltUnionCardVipServiceImpl implements HltUnionCardVipService {
@Resource
private HighDiscountPackageRecordMapper highDiscountPackageRecordMapper;
@Resource
private HighUserService highUserService;
@Resource
private HighDiscountPackageService highDiscountPackageService;
@Resource
private CommonService commonService;
@Resource
private BsCompanyService bsCompanyService;
@Resource
private HighDiscountPackageDetailsService highDiscountPackageDetailsService;
@Resource
private HighDiscountAgentRelService highDiscountAgentRelService;
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighDiscountUserRelMapper highDiscountUserRelMapper;
@Resource
private HighDiscountService highDiscountService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE)
public JSONObject GetMembershipLevel(String phone , String regionId) throws Exception {
SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
JSONObject consumptionRecord = HuiLianTongUnionCardConfig.TCheckEMsgUnionCardVipRights(phone);
JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"));
HighUser highUser = highUserService.findByPhone(phone);
if (highUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前用户不存在");
}
boolean isVip = false;
// 判断用户是否有会员权益
for (Object dataObject : cardInfoObject.getJSONArray("data")) {
JSONObject d = (JSONObject) dataObject;
if (d.getInteger("level").equals(12)) {
isVip = true;
}
}
// 判断汇联通会员等级 1-E信通会员,2-工会卡会员,12-E信通和工会卡会员
if (isVip) {
List<HighDiscountPackageRecord> list = highDiscountPackageRecordMapper.CheckCouponsMonth(highUser.getId() , 1);
// 判断当月是否赠送会员权益
if (list.size() > 0 ) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户当月已赠送");
} else {
Map<String,Object> map = new HashMap<>();
map.put("companyId", bsCompany.getId());
map.put("usingAttribution", 1);
map.put("salesType", 2);
// 查询话费专属优惠券包
List<HighDiscountPackage> highDiscountPackages = highDiscountPackageService.getDiscountPackageList(map);
if (highDiscountPackages.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂未配置专属优惠券包");
}
HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0);
Map<String , Object> mapRule = new HashMap<>();
mapRule.put("discountPackageId", highDiscountPackage.getId());
// 查询优惠券包规则
List<HighDiscountPackageDetails> discountPackageDetailsList = highDiscountPackageDetailsService.getDiscountPackageDetailsList(mapRule);
// 循环 优惠券包规则详情 列表
for (HighDiscountPackageDetails detailsList: discountPackageDetailsList) {
// 查询代理商与优惠券关系 列表
List<HighDiscountAgentRel> discountAgentRels = highDiscountAgentRelService.getRelByDiscountId(detailsList.getDiscountId().longValue());
HighDiscountAgentRel discountAgentRel = new HighDiscountAgentRel();
for (HighDiscountAgentRel discountAgentRelList: discountAgentRels) {
// 判断当前是否足够库存赠送
if (discountAgentRelList.getStockCount() > detailsList.getNum()) {
discountAgentRel = discountAgentRelList;
break;
}
}
List<HighDiscountAgentCode> discountAgentCodeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
// 赠送优惠券
for (HighDiscountAgentCode discountAgentCode : discountAgentCodeList.subList(0, detailsList.getNum())) {
HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel();
highDiscountUserRel.setDiscountId(discountAgentRel.getDiscountId());
highDiscountUserRel.setUserId(highUser.getId());
highDiscountUserRel.setAgentId(discountAgentRel.getAgentId());
highDiscountUserRel.setDiscountAgentCodeId(discountAgentCode.getId());
highDiscountUserRel.setStatus(1);
highDiscountUserRel.setCreateTime(new Date());
HighDiscount highDiscount = highDiscountService.getDiscountById(discountAgentRel.getDiscountId());
// 计算使用有效期
Calendar userEndTime = Calendar.getInstance();
userEndTime.setTime(new Date());
userEndTime.set(Calendar.HOUR_OF_DAY, 23);
userEndTime.set(Calendar.MINUTE, 59);
userEndTime.set(Calendar.SECOND, 59);
userEndTime.add(Calendar.DATE, highDiscount.getEffectiveDay());
highDiscountUserRel.setUseEndTime(userEndTime.getTime());
// 修改优惠券二维码状态
discountAgentCode.setStatus(5);
highDiscountAgentCodeService.updateCode(discountAgentCode);
// 新增优惠券与用户的绑定关系
highDiscountUserRelMapper.insert(highDiscountUserRel);
}
}
// 增加赠送记录
HighDiscountPackageRecord discountPackageRecord = new HighDiscountPackageRecord();
discountPackageRecord.setDiscountPackageId(highDiscountPackage.getId());
discountPackageRecord.setDiscountPackageTitle(highDiscountPackage.getTitle());
discountPackageRecord.setCompanyId(highDiscountPackage.getCompanyId());
discountPackageRecord.setStatus(1);
discountPackageRecord.setUsingAttribution(1);
discountPackageRecord.setRecordNo("DP" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5) );
discountPackageRecord.setSalesType(2);
discountPackageRecord.setUserId(highUser.getId().intValue());
discountPackageRecord.setExt1(highUser.getPhone());
discountPackageRecord.setCreatedTime(new Date());
highDiscountPackageRecordMapper.insert(discountPackageRecord);
}
}
return null;
}
}
Loading…
Cancel
Save