diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index fb7a13de..8265d525 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -61,7 +61,8 @@ public class HighCouponAgentController { @RequestMapping(value = "/getAgentCount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "代理商统计") - public ResponseData getAgentCount(HttpServletRequest request) { + public ResponseData getAgentCount(HttpServletRequest request, + @RequestParam(name = "type", required = true) Integer type) { try { SessionObject sessionObject = userCenter.getSessionObject(request); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); @@ -71,7 +72,28 @@ public class HighCouponAgentController { throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); } - return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId())); + return ResponseMsgUtil.success(highCouponAgentService.getSalesCountByAgent(userInfoModel.getHighAgent().getId(), type)); + + } catch (Exception e) { + log.error("HighCouponAgentController --> getCodeById() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getAgentConvertCodeCount", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "代理商兑换码统计") + public ResponseData getAgentConvertCodeCount(HttpServletRequest request) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (userInfoModel.getHighAgent() == null) { + log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + return ResponseMsgUtil.success(highCouponAgentService.getConvertCodeCountByAgent(userInfoModel.getHighAgent().getId())); } catch (Exception e) { log.error("HighCouponAgentController --> getCodeById() error!", e); @@ -187,6 +209,7 @@ public class HighCouponAgentController { if(highCouponAgentRel.getCouponId() == null || highCouponAgentRel.getAgentId() == null + || highCouponAgentRel.getType() == null || highCouponAgentRel.getStockCount() == null) { log.error("HighCouponAgentController -> assignCouponAgent() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -207,7 +230,7 @@ public class HighCouponAgentController { } // 校验是否分配过 - HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId()); + HighCouponAgentRel couponAgent = highCouponAgentService.getRelByCouponAgent(highCouponAgentRel.getCouponId(), highCouponAgentRel.getAgentId(), highCouponAgentRel.getType()); if (couponAgent != null) { couponAgent.setStockCount(couponAgent.getStockCount() + highCouponAgentRel.getStockCount()); couponAgent.setOperatorId(userInfoModel.getSecUser().getId()); @@ -290,6 +313,7 @@ public class HighCouponAgentController { @ResponseBody @ApiOperation(value = "根据代理商和卡券 查询分配的销售码") public ResponseData getCodeListByAgentCoupon(@RequestParam(name = "couponId", required = true) Long couponId, + @RequestParam(name = "type", required = true) Integer type, @RequestParam(name = "status", required = false) String status, @RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "createTimeE", required = false) Long createTimeE, @@ -307,6 +331,7 @@ public class HighCouponAgentController { Map map = new HashMap<>(); map.put("agentId", userInfoModel.getHighAgent().getId()); + map.put("type", type); map.put("couponId", couponId); map.put("status", status); map.put("createTimeS", createTimeS); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index e8bd2408..0b55d2ff 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -12,7 +12,7 @@ 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.generateCode; +import com.hai.common.GenerateCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; @@ -620,7 +620,7 @@ public class HighCouponController { highCouponCode = new HighCouponCode(); highCouponCode.setCouponId(couponId); highCouponCode.setMerchantId(coupon.getMerchantId()); - highCouponCode.setSalesCode(generateCode.couponSalesCode(coupon.getMerchantId(), couponId)); + highCouponCode.setSalesCode(GenerateCode.couponSalesCode(coupon.getMerchantId(), couponId)); highCouponCode.setSalesEndTime(salesEndTimeC.getTime()); highCouponCode.setUseEndTime(useEndTimeC.getTime()); highCouponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java index b4d9072a..ae72ed98 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountPackageController.java @@ -252,7 +252,7 @@ public class HighDiscountPackageController { highDiscountPackage.setCompanyId(highDiscountPackages.getCompanyId()); highDiscountPackage.setCreatedUserId(highDiscountPackages.getCreatedUserId()); highDiscountPackage.setCreatedTime(highDiscountPackages.getCreatedTime()); - highDiscountPackage.setTotalStock(highDiscountPackage.getTotalStock()); + highDiscountPackage.setTotalStock(highDiscountPackages.getTotalStock()); highDiscountPackageService.updateDiscountPackage(highDiscountPackage); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java index 3be23e37..b75965ae 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOrderController.java @@ -36,10 +36,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.math.BigDecimal; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @Auther: 袁野 @@ -607,9 +604,14 @@ public class HighOrderController { JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); + if (jsonObject == null) { + log.error("orderToPay error!", "请求超时"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); + } + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); - if (dataObject.getBoolean("success")) { + if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { order.setOrderStatus(4); order.setRefundTime(new Date()); order.setRefundContent(dataObject.getString("orderId")); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index f4161e99..ed309457 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -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); @Resource private HltUnionCardVipService hltUnionCardVipService; @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); return ResponseMsgUtil.exception(e); } } @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); JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); return ResponseMsgUtil.success(cardInfoObject); } 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); } } } \ No newline at end of file +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); @Resource private HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; // @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); // return ResponseMsgUtil.exception(e); // } // } // // @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); // JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")); // return ResponseMsgUtil.success(cardInfoObject); // } 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); // } // } // // @RequestMapping(value="/getReadFile",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "存入用户信息") // public ResponseData getReadFile() { // try { // highTestService.getReadFile(); // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } // @RequestMapping(value="/getUserDiscount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "赠送优惠券") public ResponseData getUserDiscount(@RequestParam(name = "id", required = true) Long id) { try { highTestService.getUserDiscount(id); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java index c065c33b..ef63b265 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -16,6 +16,7 @@ import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.config.UnionPayConfig; import com.hai.entity.HighRefundAudit; import com.hai.entity.OutRechargeOrder; import com.hai.model.*; @@ -260,33 +261,8 @@ public class OutRechargeOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); } - if (order.getPayType() == 2) { - JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); - - if (jsonObject == null) { - log.error("orderToPay error!", "请求超时"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); - } - - JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); - - if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { - order.setStatus(5); - order.setRefundTime(new Date()); - order.setOutRefundNo("HFR"+new Date().getTime() ); - order.setRefundFee(order.getPayRealPrice()); - order.setRefundId(dataObject.getString("orderId")); - - highRefundAudit.setStatus(1); - highRefundAuditService.updateRefundAudit(highRefundAudit); - outRechargeOrderService.updateOrder(order); - return ResponseMsgUtil.success("退款成功"); - } else { - log.error("orderToPay error!", dataObject.getString("message")); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); - } - - } else { + // 微信退款 + if (order.getPayType() == 1) { Map param = new HashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); @@ -312,13 +288,57 @@ public class OutRechargeOrderController { outRechargeOrderService.updateOrder(order); highRefundAudit.setStatus(1); highRefundAuditService.updateRefundAudit(highRefundAudit); - return ResponseMsgUtil.success("退款成功"); } else { log.error("orderToPay error!", "退款失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); } } + // 工会卡退款 + if (order.getPayType() == 2) { + JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); + + if (jsonObject == null) { + log.error("orderToPay error!", "请求超时"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); + } + + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); + + if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { + order.setStatus(5); + order.setRefundTime(new Date()); + order.setOutRefundNo("HFR"+new Date().getTime() ); + order.setRefundFee(order.getPayRealPrice()); + order.setRefundId(dataObject.getString("orderId")); + + highRefundAudit.setStatus(1); + highRefundAuditService.updateRefundAudit(highRefundAudit); + outRechargeOrderService.updateOrder(order); + + } else { + log.error("orderToPay error!", dataObject.getString("message")); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); + } + } + + // 银联退款 + if (order.getPayType() == 4) { + // 订单退款 + JSONObject refund = UnionPayConfig.zwrefund(order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); + if (!refund.getString("resultcode").equals("W6")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); + } + + order.setStatus(5); + order.setRefundTime(new Date()); + order.setOutRefundNo(refund.getString("oriwtorderid")); + order.setRefundFee(order.getPayRealPrice()); + highRefundAudit.setStatus(1); + highRefundAuditService.updateRefundAudit(highRefundAudit); + outRechargeOrderService.updateOrder(order); + } + return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getUserOrderList() error!", e); return ResponseMsgUtil.exception(e); diff --git a/hai-bweb/src/main/resources/dev/application.yml b/hai-bweb/src/main/resources/dev/application.yml index f799126d..6dbeaaea 100644 --- a/hai-bweb/src/main/resources/dev/application.yml +++ b/hai-bweb/src/main/resources/dev/application.yml @@ -28,11 +28,11 @@ spring: poolPreparedStatements: true maxOpenPreparedStatements: 20 redis: - database: 0 + database: 5 host: 139.159.177.244 port: 36379 password: HF123456.Redis - timeout: 1000 + timeout: 36000000 jedis: pool: max-active: 20 diff --git a/hai-bweb/src/main/resources/pre/application.yml b/hai-bweb/src/main/resources/pre/application.yml index 4c2e5f66..f945f8c0 100644 --- a/hai-bweb/src/main/resources/pre/application.yml +++ b/hai-bweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index c119e8c6..b6ce7d39 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -93,6 +93,8 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/order/*") .excludePathPatterns("/coupon/getCouponList") .excludePathPatterns("/wechatpay/*") + .excludePathPatterns("/couponAgent/useConvertCode") + .excludePathPatterns("/couponAgent/convertCodeDetail") .excludePathPatterns("/coupon/getCouponById") .excludePathPatterns("/discount/getDiscountByQrCode") .excludePathPatterns("/discount/getDiscountById") @@ -129,7 +131,6 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/highBrand/*") .excludePathPatterns("/highGoodsType/*") .excludePathPatterns("/sendSms/*") - .excludePathPatterns("/test/*") .excludePathPatterns("/sms/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index 26c25e49..a8945cfa 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -55,7 +55,7 @@ public class CmsContentController { map.put("companyId", bsCompany.getId().toString()); map.put("status", "2"); map.put("categoryCode", categoryCode); - return ResponseMsgUtil.success(cmsContentService.getListContent(map)); + return ResponseMsgUtil.success(cmsContentService.getListContentByCrest(map)); } } return ResponseMsgUtil.success(new ArrayList<>()); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java new file mode 100644 index 00000000..f627d928 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java @@ -0,0 +1,114 @@ +package com.cweb.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.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.*; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DeadlockLoserDataAccessException; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.*; + +/** + * @Auther: 胡锐 + * @Description: + * @Date: 2021/4/20 23:47 + */ +@Controller +@RequestMapping(value = "/couponAgent") +@Api(value = "代理商接口") +public class HighCouponAgentController { + + private static Logger log = LoggerFactory.getLogger(HighCouponAgentController.class); + + @Resource + private HighCouponAgentService highCouponAgentService; + + @Resource + private HighCouponService highCouponService; + + @Resource + private HighCouponCodeService highCouponCodeService; + + @RequestMapping(value = "/useConvertCode", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "兑换码使用") + public ResponseData useConvertCode(@RequestBody JSONObject body) { + try { + + if (body == null || StringUtils.isBlank(body.getString("code"))) { + log.error("HighCouponAgentController -> queryConvertCode() error!",""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询兑换码 + HighCouponAgentCode convertCode = highCouponAgentService.getConvertCode(body.getString("code")); + if (convertCode == null) { + log.error("HighCouponAgentController -> queryConvertCode() error!","无效的兑换码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); + } + if (convertCode.getStatus() == 3) { + log.error("HighCouponAgentController -> queryConvertCode() error!","兑换码已被使用"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + if (convertCode.getCouponCodeId() != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code"))); + + } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { + log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); + return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null); + + } catch (Exception e) { + log.error("HighCouponAgentController --> useConvertCode() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/convertCodeDetail", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "兑换码详情") + public ResponseData convertCodeDetail(@RequestParam(name = "code", required = true) String code) { + try { + + // 查询兑换码 + HighCouponAgentCode couponAgentCode = highCouponAgentService.getConvertCode(code); + if (couponAgentCode == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到销售码"); + } + + Map map = new HashMap<>(); + map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId())); + map.put("couponCode", highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId())); + map.put("couponAgentCode", couponAgentCode); + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("HighCouponAgentController --> getConvertCodeDetail() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index ddee2d97..faebbc10 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -53,9 +53,6 @@ public class HighCouponController { @Resource private HighCouponCodeService highCouponCodeService; - @Resource - private HighOrderService highOrderService; - @Resource private HighUserCouponService highUserCouponService; 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 76b425c3..b91740c8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -272,6 +272,29 @@ public class HighOrderController { childOrder.setGoodsSpecName("默认"); } + // 汇联通充值 + if (childOrder.getGoodsType() == 8) { + if (childOrder.getGoodsPrice() == null) { + log.error("HighOrderController --> addOrder() error!", "请设置充值金额"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额"); + } + if (highOrder.getMemCardNo() == null) { + log.error("HighOrderController --> addOrder() error!", "请设置充值卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值卡号"); + } + // 查询用户信息 + HighUser user = highUserService.findByUserId(childOrder.getGoodsId()); + if (user == null) { + log.error("HighOrderController --> addOrder() error!", "未找到用户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); + } + highOrder.setPayType(2); // 第三方平台 + childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); + childOrder.setGoodsName(user.getName()); + childOrder.setGoodsImg(user.getHeaderImg()); + childOrder.setGoodsSpecName("默认"); + } + childOrder.setMemId(userInfoModel.getHighUser().getId()); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是 @@ -346,7 +369,7 @@ public class HighOrderController { // 卡卷类型 1:满减 2:抵扣 3:折扣 if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { // 折扣除100 - BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice().divide(new BigDecimal("10")); + BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); // 订单总额 * 折扣 BigDecimal payPrice = highOrder.getTotalPrice().multiply(discountPrice); highOrder.setDeductionPrice(highOrder.getTotalPrice().subtract(payPrice)); diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 3028651a..eaf05c11 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -122,15 +122,16 @@ public class OutRechargeOrderController { // 支付类型 1.微信支付 outRechargeOrder.setPayType(1); // 判断充值模式:1 电信 2. 移动 3. 联通 - JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); - if (telObject.get("status").equals(0)) { - JSONObject o = telObject.getObject("result",JSONObject.class); - // 拼接内容 - remarks = o.get("province").toString() + o.get("company").toString() + "充值" + outRechargeOrder.getOrderPrice() + "元"; - } else { - log.error("orderToPay error!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); - } + // 拼接内容 + remarks = outRechargeOrder.getRechargeContent() + "充值" + outRechargeOrder.getOrderPrice() + "元"; +// JSONObject telObject = telApiService.outApiTel(outRechargeOrder.getRechargeContent()); +// if (telObject.get("status").equals(0)) { +// JSONObject o = telObject.getObject("result",JSONObject.class); +// +// } else { +// log.error("orderToPay error!"); +// throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_IS_ERROR); +// } HighDiscountUserRel highDiscountUserRel = null; if (outRechargeOrder.getMemDiscountId() != null) { @@ -186,8 +187,7 @@ public class OutRechargeOrderController { // 卡卷类型 1:满减 2:抵扣 3:折扣 if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { - // 折扣除100 - BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice().divide(new BigDecimal("10")); + BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); // 订单总额 * 折扣 BigDecimal payPrice = outRechargeOrder.getOrderPrice().multiply(discountPrice); outRechargeOrder.setDeductionPrice(outRechargeOrder.getOrderPrice().subtract(payPrice)); diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java index 90cc8087..9e5a8ed6 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java @@ -59,7 +59,8 @@ public class OutRechargePriceController { @ApiOperation(value = "查询充值金额列表") public ResponseData getListOutRechargePrice( @RequestParam(value = "type", required = false) Integer type, - @RequestParam(name = "regionId", required = true) String regionId + @RequestParam(name = "regionId", required = true) String regionId, + @RequestParam(name = "showType", required = true) Integer showType ) { try { Map map = new HashMap<>(); @@ -71,8 +72,11 @@ public class OutRechargePriceController { } if (type != null ) { - map.put("type", String.valueOf(type)); + map.put("showType", String.valueOf(showType)); + } + if (type != null ) { + map.put("type", String.valueOf(type)); } return ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map)); diff --git a/hai-cweb/src/main/resources/pre/application.yml b/hai-cweb/src/main/resources/pre/application.yml index 1012ea5c..f425a243 100644 --- a/hai-cweb/src/main/resources/pre/application.yml +++ b/hai-cweb/src/main/resources/pre/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://122.9.135.148:3306/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/test/common/test.java b/hai-cweb/src/test/common/test.java index d88c1ee4..41a01fe1 100644 --- a/hai-cweb/src/test/common/test.java +++ b/hai-cweb/src/test/common/test.java @@ -46,7 +46,7 @@ public class test { @Test public void test(){ -/* List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); + List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(55L); List userList = highUserService.getUserList(); @@ -55,7 +55,7 @@ public class test { // 领取优惠券 highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); num++; - }*/ + } } diff --git a/hai-service/src/main/java/com/hai/common/generateCode.java b/hai-service/src/main/java/com/hai/common/GenerateCode.java similarity index 56% rename from hai-service/src/main/java/com/hai/common/generateCode.java rename to hai-service/src/main/java/com/hai/common/GenerateCode.java index aa6d1c27..ac87b81d 100644 --- a/hai-service/src/main/java/com/hai/common/generateCode.java +++ b/hai-service/src/main/java/com/hai/common/GenerateCode.java @@ -1,5 +1,6 @@ package com.hai.common; +import java.security.SecureRandom; import java.util.Calendar; import java.util.Random; @@ -8,8 +9,11 @@ import java.util.Random; * @Description: * @Date: 2021/3/18 21:07 */ -public class generateCode { +public class GenerateCode { + private static final Random RANDOM = new SecureRandom(); + + private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; /** * @Author 胡锐 @@ -33,4 +37,23 @@ public class generateCode { } return val; } + + /** + * 生成兑换码 + * @param couponAgentRelId + * @return + */ + public static String convertCode(Long couponAgentRelId) { + // 兑换码总长度 + int countLength = 20; + // 需要生成的长度 + int generateLength = countLength - couponAgentRelId.toString().length(); + + char[] nonceChars = new char[generateLength]; + for (int index = 0; index < nonceChars.length; ++index) { + nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length())); + } + return new String(nonceChars) + couponAgentRelId; + } + } diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index 4fd33a61..5b0f4d55 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -121,6 +121,31 @@ public class HuiLianTongUnionCardConfig { } } + /** + * 充值 + * @param orderNo 订单号 + * @param cardNo 卡号 + * @param tranAmount 支付金额 + * @param businessType 业务类型 1.卖中石化加油券的,固定填sinopec_oil_code 2.其他商品或服务的,固定填hisen_consume + * @param tranVoucher 银行卡充值可填银行卡号;支付宝、微信充值可填相应的扣款单号;接入方也可自定义填入交易流水跟踪号,但长度不能超过50 + * @param tranDesc 交易描述 + * @return + * @throws Exception + */ + public static JSONObject deposit(String orderNo, String cardNo, BigDecimal tranAmount, String businessType, String tranVoucher , String tranDesc) throws Exception { + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", orderNo); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", cardNo); + dataMap.put("tranAmount", tranAmount); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("tranVoucher", tranVoucher); + dataMap.put("tranDesc", tranDesc); + System.out.println("工会卡支付请求参数" + JSON.toJSONString(dataMap)); + return request("qtk/deposit", dataMap); + } + /** * 支付 * @param orderNo 订单号 diff --git a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java index 1e78cfbd..443f9ff3 100644 --- a/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/CmsContentMapperExt.java @@ -44,7 +44,7 @@ public interface CmsContentMapperExt { " AND cc.status = #{status}", " ", "", - "ORDER BY cc.category_code", + "ORDER BY cc.category_code and cc.sort_id", "" }) @Results({ @@ -76,4 +76,67 @@ public interface CmsContentMapperExt { }) List getListContent(Map paramsMap) throws Exception; + + @Select(value = { + "" + }) + @Results({ + @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), + @Result(column="title", property="title", jdbcType= JdbcType.VARCHAR), + @Result(column="category_id", property="categoryId", jdbcType= JdbcType.BIGINT), + @Result(column="category_code", property="categoryCode", jdbcType= JdbcType.VARCHAR), + @Result(column="description", property="description", jdbcType= JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType= JdbcType.INTEGER), + @Result(column="has_patch", property="hasPatch", jdbcType= JdbcType.TINYINT), + @Result(column="visit_count", property="visitCount", jdbcType= JdbcType.INTEGER), + @Result(column="tag", property="tag", jdbcType= JdbcType.VARCHAR), + @Result(column="img_source", property="imgSource", jdbcType= JdbcType.TINYINT), + @Result(column="img_data", property="imgData", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_type", property="jumpType", jdbcType= JdbcType.INTEGER), + @Result(column="jump_name", property="jumpName", jdbcType= JdbcType.VARCHAR), + @Result(column="jump_url", property="jumpUrl", jdbcType= JdbcType.VARCHAR), + @Result(column="sort_id", property="sortId", jdbcType= JdbcType.INTEGER), + @Result(column="update_time", property="updateTime", jdbcType= JdbcType.TIMESTAMP), + @Result(column="recommend", property="recommend", jdbcType= JdbcType.BIT), + @Result(column="company_id", property="companyId", jdbcType= JdbcType.BIGINT), + @Result(column="op_id", property="opId", jdbcType= JdbcType.BIGINT), + @Result(column="ext_1", property="ext1", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType= JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType= JdbcType.VARCHAR), + @Result(column="content", property="content", jdbcType= JdbcType.LONGVARCHAR), + @Result(column="category_name", property="categoryName", jdbcType= JdbcType.VARCHAR), + }) + List getListContentByCrest(Map paramsMap) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java index f876a552..92cb7f29 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java @@ -39,16 +39,18 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_agent_code (coupon_agent_id, coupon_id, ", - "agent_id, coupon_code_id, ", - "coupon_agent_record_id, coupon_code, ", + "insert into high_coupon_agent_code (`type`, coupon_agent_id, ", + "coupon_id, agent_id, ", + "coupon_agent_record_id, convert_code, ", + "coupon_code_id, coupon_code, ", "qr_code, `status`, ", "remark, create_time, ", "operator_id, operator_name, ", "ext_1, ext_2, ext_3)", - "values (#{couponAgentId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ", - "#{agentId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ", - "#{couponAgentRecordId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", + "values (#{type,jdbcType=INTEGER}, #{couponAgentId,jdbcType=BIGINT}, ", + "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", + "#{couponAgentRecordId,jdbcType=BIGINT}, #{convertCode,jdbcType=VARCHAR}, ", + "#{couponCodeId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", "#{qrCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", @@ -64,11 +66,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @SelectProvider(type=HighCouponAgentCodeSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), - @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), + @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -84,19 +88,21 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Select({ "select", - "id, coupon_agent_id, coupon_id, agent_id, coupon_code_id, coupon_agent_record_id, ", - "coupon_code, qr_code, `status`, remark, create_time, operator_id, operator_name, ", - "ext_1, ext_2, ext_3", + "id, `type`, coupon_agent_id, coupon_id, agent_id, coupon_agent_record_id, convert_code, ", + "coupon_code_id, coupon_code, qr_code, `status`, remark, create_time, operator_id, ", + "operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_code", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_agent_id", property="couponAgentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), - @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), + @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @@ -121,11 +127,13 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Update({ "update high_coupon_agent_code", - "set coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},", + "set `type` = #{type,jdbcType=INTEGER},", + "coupon_agent_id = #{couponAgentId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", - "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT},", + "convert_code = #{convertCode,jdbcType=VARCHAR},", + "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_code = #{couponCode,jdbcType=VARCHAR},", "qr_code = #{qrCode,jdbcType=VARCHAR},", "`status` = #{status,jdbcType=INTEGER},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java index 3ff4fd78..50f71478 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java @@ -28,6 +28,10 @@ public class HighCouponAgentCodeSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("high_coupon_agent_code"); + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.VALUES("coupon_agent_id", "#{couponAgentId,jdbcType=BIGINT}"); } @@ -40,14 +44,18 @@ public class HighCouponAgentCodeSqlProvider { sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.VALUES("coupon_agent_record_id", "#{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.VALUES("convert_code", "#{convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.VALUES("coupon_code", "#{couponCode,jdbcType=VARCHAR}"); } @@ -98,11 +106,13 @@ public class HighCouponAgentCodeSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("`type`"); sql.SELECT("coupon_agent_id"); sql.SELECT("coupon_id"); sql.SELECT("agent_id"); - sql.SELECT("coupon_code_id"); sql.SELECT("coupon_agent_record_id"); + sql.SELECT("convert_code"); + sql.SELECT("coupon_code_id"); sql.SELECT("coupon_code"); sql.SELECT("qr_code"); sql.SELECT("`status`"); @@ -134,6 +144,10 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); } @@ -146,14 +160,18 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); } @@ -203,11 +221,13 @@ public class HighCouponAgentCodeSqlProvider { sql.UPDATE("high_coupon_agent_code"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("coupon_agent_id = #{record.couponAgentId,jdbcType=BIGINT}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); - sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); + sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); + sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); @@ -228,6 +248,10 @@ public class HighCouponAgentCodeSqlProvider { SQL sql = new SQL(); sql.UPDATE("high_coupon_agent_code"); + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + if (record.getCouponAgentId() != null) { sql.SET("coupon_agent_id = #{couponAgentId,jdbcType=BIGINT}"); } @@ -240,14 +264,18 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("agent_id = #{agentId,jdbcType=BIGINT}"); } - if (record.getCouponCodeId() != null) { - sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); - } - if (record.getCouponAgentRecordId() != null) { sql.SET("coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertCode() != null) { + sql.SET("convert_code = #{convertCode,jdbcType=VARCHAR}"); + } + + if (record.getCouponCodeId() != null) { + sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); + } + if (record.getCouponCode() != null) { sql.SET("coupon_code = #{couponCode,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java index a166f0ee..3cf1e4e3 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapper.java @@ -39,18 +39,20 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_agent_rel (coupon_name, sales_price, ", - "coupon_id, agent_id, ", - "stock_count, sales_count, ", - "create_time, `status`, ", - "operator_id, operator_name, ", - "ext_1, ext_2, ext_3)", - "values (#{couponName,jdbcType=VARCHAR}, #{salesPrice,jdbcType=DECIMAL}, ", - "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", - "#{stockCount,jdbcType=INTEGER}, #{salesCount,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", - "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "insert into high_coupon_agent_rel (`type`, coupon_name, ", + "sales_price, coupon_id, ", + "agent_id, stock_count, ", + "sales_count, create_time, ", + "`status`, operator_id, ", + "operator_name, ext_1, ", + "ext_2, ext_3)", + "values (#{type,jdbcType=INTEGER}, #{couponName,jdbcType=VARCHAR}, ", + "#{salesPrice,jdbcType=DECIMAL}, #{couponId,jdbcType=BIGINT}, ", + "#{agentId,jdbcType=BIGINT}, #{stockCount,jdbcType=INTEGER}, ", + "#{salesCount,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ", + "#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighCouponAgentRel record); @@ -62,6 +64,7 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @SelectProvider(type=HighCouponAgentRelSqlProvider.class, method="selectByExample") @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @@ -80,13 +83,14 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Select({ "select", - "id, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", + "id, `type`, coupon_name, sales_price, coupon_id, agent_id, stock_count, sales_count, ", "create_time, `status`, operator_id, operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_rel", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), @Result(column="coupon_name", property="couponName", jdbcType=JdbcType.VARCHAR), @Result(column="sales_price", property="salesPrice", jdbcType=JdbcType.DECIMAL), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @@ -114,7 +118,8 @@ public interface HighCouponAgentRelMapper extends HighCouponAgentRelMapperExt { @Update({ "update high_coupon_agent_rel", - "set coupon_name = #{couponName,jdbcType=VARCHAR},", + "set `type` = #{type,jdbcType=INTEGER},", + "coupon_name = #{couponName,jdbcType=VARCHAR},", "sales_price = #{salesPrice,jdbcType=DECIMAL},", "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java index 818a82f5..342cddf2 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelMapperExt.java @@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Select; import org.apache.ibatis.type.JdbcType; import java.util.List; +import java.util.Map; /** @@ -21,11 +22,11 @@ public interface HighCouponAgentRelMapperExt { " case when sum(c.sales_price) is not null then sum(c.sales_price) else 0 end salesCountPrice " + " from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c" + " where c.id = a.coupon_agent_id and c.agent_id = #{agentId}" + - " and a.status = 3 and a.coupon_code_id = b.id and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE}") + " and b.status = 3 and a.coupon_code_id = b.id and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE}") AgentSalesModel getAgentSales(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE); @Select(" select a.* from high_coupon_agent_code a,high_coupon_code b,high_coupon_agent_rel c " + - " where c.id = a.coupon_agent_id and c.agent_id = #{agentId} and a.status = 3 and a.coupon_code_id = b.id " + + " where c.id = a.coupon_agent_id and c.agent_id = #{agentId} and b.`status` = 3 and a.coupon_code_id = b.id " + " and b.consume_time >= #{consumeTimeS} and b.consume_time <= #{consumeTimeE} ORDER BY b.consume_time desc") @Results({ @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true), @@ -47,6 +48,37 @@ public interface HighCouponAgentRelMapperExt { }) List getAgentSalesCodeList(@Param("agentId") Long agentId, @Param("consumeTimeS")String consumeTimeS, @Param("consumeTimeE")String consumeTimeE); - @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (#{status}) ") - Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status); + @Select(" select count(1) from high_coupon_agent_code a where a.agent_id = #{agentId} and a.`status` in (${status}) and a.type = #{type} ") + Integer getAgentCodeCount(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type); + + @Select(" select " + + " case WHEN sum(b.sales_price) is null then 0 else sum(b.sales_price) end" + + " from high_coupon_agent_code a " + + " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id " + + " where a.agent_id = #{agentId} and a.`status` in (${status}) and a.type = #{type} ") + Integer getAgentCodePrice(@Param("agentId") Long agentId,@Param("status") String status,@Param("type") Integer type); + + @Select(" select " + + " a.id," + + " a.noUsedNum, " + + " (a.noUsedNum * a.price) noUsedPrice," + + " b.usedNum," + + " (b.usedNum * b.price) usedPrice" + + " from (" + + " select " + + " b.id," + + " count(1) noUsedNum," + + " b.sales_price price" + + " from high_coupon_agent_code a " + + " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id" + + " where b.id = #{couponAgentRelId} and a.`status` = 2) a," + + " (select " + + " b.id," + + " count(1) usedNum," + + " b.sales_price price" + + " from high_coupon_agent_code a" + + " LEFT JOIN high_coupon_agent_rel b on b.id = a.coupon_agent_id" + + " where b.id = #{couponAgentRelId} and a.`status` = 3) b" + + " where a.id = b.id ") + Map getUseNum(@Param("couponAgentRelId") Long couponAgentRelId); } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java index 7783432a..13d0d982 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentRelSqlProvider.java @@ -28,6 +28,10 @@ public class HighCouponAgentRelSqlProvider { SQL sql = new SQL(); sql.INSERT_INTO("high_coupon_agent_rel"); + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.VALUES("coupon_name", "#{couponName,jdbcType=VARCHAR}"); } @@ -90,6 +94,7 @@ public class HighCouponAgentRelSqlProvider { } else { sql.SELECT("id"); } + sql.SELECT("`type`"); sql.SELECT("coupon_name"); sql.SELECT("sales_price"); sql.SELECT("coupon_id"); @@ -124,6 +129,10 @@ public class HighCouponAgentRelSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); } + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); } @@ -185,6 +194,7 @@ public class HighCouponAgentRelSqlProvider { sql.UPDATE("high_coupon_agent_rel"); sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); sql.SET("coupon_name = #{record.couponName,jdbcType=VARCHAR}"); sql.SET("sales_price = #{record.salesPrice,jdbcType=DECIMAL}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); @@ -208,6 +218,10 @@ public class HighCouponAgentRelSqlProvider { SQL sql = new SQL(); sql.UPDATE("high_coupon_agent_rel"); + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + if (record.getCouponName() != null) { sql.SET("coupon_name = #{couponName,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java index 7aad31a7..ffc657a7 100644 --- a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java @@ -44,7 +44,7 @@ public class HighChildOrder implements Serializable { private String storeAddress; /** - * 商品类型 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 + * 商品类型 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 8: 汇联通充值 */ private Integer goodsType; @@ -524,4 +524,4 @@ public class HighChildOrder implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java index 1fae72af..6b21861f 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java @@ -20,6 +20,11 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser */ private Long id; + /** + * 类型 1:销售码 2:兑换码 + */ + private Integer type; + /** * 卡券和代理商的id */ @@ -36,14 +41,19 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser private Long agentId; /** - * 销售码id + * 卡券分配给代理商库存记录id */ - private Long couponCodeId; + private Long couponAgentRecordId; /** - * 卡券分配给代理商库存记录id + * 兑换码 */ - private Long couponAgentRecordId; + private String convertCode; + + /** + * 销售码id + */ + private Long couponCodeId; /** * 销售码 @@ -96,6 +106,14 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.id = id; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + public Long getCouponAgentId() { return couponAgentId; } @@ -120,14 +138,6 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.agentId = agentId; } - public Long getCouponCodeId() { - return couponCodeId; - } - - public void setCouponCodeId(Long couponCodeId) { - this.couponCodeId = couponCodeId; - } - public Long getCouponAgentRecordId() { return couponAgentRecordId; } @@ -136,6 +146,22 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.couponAgentRecordId = couponAgentRecordId; } + public String getConvertCode() { + return convertCode; + } + + public void setConvertCode(String convertCode) { + this.convertCode = convertCode; + } + + public Long getCouponCodeId() { + return couponCodeId; + } + + public void setCouponCodeId(Long couponCodeId) { + this.couponCodeId = couponCodeId; + } + public String getCouponCode() { return couponCode; } @@ -229,11 +255,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser } HighCouponAgentCode other = (HighCouponAgentCode) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getCouponAgentId() == null ? other.getCouponAgentId() == null : this.getCouponAgentId().equals(other.getCouponAgentId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) - && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponAgentRecordId() == null ? other.getCouponAgentRecordId() == null : this.getCouponAgentRecordId().equals(other.getCouponAgentRecordId())) + && (this.getConvertCode() == null ? other.getConvertCode() == null : this.getConvertCode().equals(other.getConvertCode())) + && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode())) && (this.getQrCode() == null ? other.getQrCode() == null : this.getQrCode().equals(other.getQrCode())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) @@ -251,11 +279,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getCouponAgentId() == null) ? 0 : getCouponAgentId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); - result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponAgentRecordId() == null) ? 0 : getCouponAgentRecordId().hashCode()); + result = prime * result + ((getConvertCode() == null) ? 0 : getConvertCode().hashCode()); + result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode()); result = prime * result + ((getQrCode() == null) ? 0 : getQrCode().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); @@ -276,11 +306,13 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", type=").append(type); sb.append(", couponAgentId=").append(couponAgentId); sb.append(", couponId=").append(couponId); sb.append(", agentId=").append(agentId); - sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponAgentRecordId=").append(couponAgentRecordId); + sb.append(", convertCode=").append(convertCode); + sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponCode=").append(couponCode); sb.append(", qrCode=").append(qrCode); sb.append(", status=").append(status); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java index fbd038f7..cccf62bb 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java @@ -185,6 +185,66 @@ public class HighCouponAgentCodeExample { return (Criteria) this; } + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + public Criteria andCouponAgentIdIsNull() { addCriterion("coupon_agent_id is null"); return (Criteria) this; @@ -365,123 +425,193 @@ public class HighCouponAgentCodeExample { return (Criteria) this; } - public Criteria andCouponCodeIdIsNull() { - addCriterion("coupon_code_id is null"); + public Criteria andCouponAgentRecordIdIsNull() { + addCriterion("coupon_agent_record_id is null"); return (Criteria) this; } - public Criteria andCouponCodeIdIsNotNull() { - addCriterion("coupon_code_id is not null"); + public Criteria andCouponAgentRecordIdIsNotNull() { + addCriterion("coupon_agent_record_id is not null"); return (Criteria) this; } - public Criteria andCouponCodeIdEqualTo(Long value) { - addCriterion("coupon_code_id =", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdEqualTo(Long value) { + addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotEqualTo(Long value) { - addCriterion("coupon_code_id <>", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotEqualTo(Long value) { + addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdGreaterThan(Long value) { - addCriterion("coupon_code_id >", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdGreaterThan(Long value) { + addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) { - addCriterion("coupon_code_id >=", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) { + addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdLessThan(Long value) { - addCriterion("coupon_code_id <", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdLessThan(Long value) { + addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) { - addCriterion("coupon_code_id <=", value, "couponCodeId"); + public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) { + addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdIn(List values) { - addCriterion("coupon_code_id in", values, "couponCodeId"); + public Criteria andCouponAgentRecordIdIn(List values) { + addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotIn(List values) { - addCriterion("coupon_code_id not in", values, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotIn(List values) { + addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdBetween(Long value1, Long value2) { - addCriterion("coupon_code_id between", value1, value2, "couponCodeId"); + public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) { + addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) { - addCriterion("coupon_code_id not between", value1, value2, "couponCodeId"); + public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) { + addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIsNull() { - addCriterion("coupon_agent_record_id is null"); + public Criteria andConvertCodeIsNull() { + addCriterion("convert_code is null"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIsNotNull() { - addCriterion("coupon_agent_record_id is not null"); + public Criteria andConvertCodeIsNotNull() { + addCriterion("convert_code is not null"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdEqualTo(Long value) { - addCriterion("coupon_agent_record_id =", value, "couponAgentRecordId"); + public Criteria andConvertCodeEqualTo(String value) { + addCriterion("convert_code =", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotEqualTo(Long value) { - addCriterion("coupon_agent_record_id <>", value, "couponAgentRecordId"); + public Criteria andConvertCodeNotEqualTo(String value) { + addCriterion("convert_code <>", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdGreaterThan(Long value) { - addCriterion("coupon_agent_record_id >", value, "couponAgentRecordId"); + public Criteria andConvertCodeGreaterThan(String value) { + addCriterion("convert_code >", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdGreaterThanOrEqualTo(Long value) { - addCriterion("coupon_agent_record_id >=", value, "couponAgentRecordId"); + public Criteria andConvertCodeGreaterThanOrEqualTo(String value) { + addCriterion("convert_code >=", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdLessThan(Long value) { - addCriterion("coupon_agent_record_id <", value, "couponAgentRecordId"); + public Criteria andConvertCodeLessThan(String value) { + addCriterion("convert_code <", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdLessThanOrEqualTo(Long value) { - addCriterion("coupon_agent_record_id <=", value, "couponAgentRecordId"); + public Criteria andConvertCodeLessThanOrEqualTo(String value) { + addCriterion("convert_code <=", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdIn(List values) { - addCriterion("coupon_agent_record_id in", values, "couponAgentRecordId"); + public Criteria andConvertCodeLike(String value) { + addCriterion("convert_code like", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotIn(List values) { - addCriterion("coupon_agent_record_id not in", values, "couponAgentRecordId"); + public Criteria andConvertCodeNotLike(String value) { + addCriterion("convert_code not like", value, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdBetween(Long value1, Long value2) { - addCriterion("coupon_agent_record_id between", value1, value2, "couponAgentRecordId"); + public Criteria andConvertCodeIn(List values) { + addCriterion("convert_code in", values, "convertCode"); return (Criteria) this; } - public Criteria andCouponAgentRecordIdNotBetween(Long value1, Long value2) { - addCriterion("coupon_agent_record_id not between", value1, value2, "couponAgentRecordId"); + public Criteria andConvertCodeNotIn(List values) { + addCriterion("convert_code not in", values, "convertCode"); + return (Criteria) this; + } + + public Criteria andConvertCodeBetween(String value1, String value2) { + addCriterion("convert_code between", value1, value2, "convertCode"); + return (Criteria) this; + } + + public Criteria andConvertCodeNotBetween(String value1, String value2) { + addCriterion("convert_code not between", value1, value2, "convertCode"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIsNull() { + addCriterion("coupon_code_id is null"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIsNotNull() { + addCriterion("coupon_code_id is not null"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdEqualTo(Long value) { + addCriterion("coupon_code_id =", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotEqualTo(Long value) { + addCriterion("coupon_code_id <>", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdGreaterThan(Long value) { + addCriterion("coupon_code_id >", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdGreaterThanOrEqualTo(Long value) { + addCriterion("coupon_code_id >=", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdLessThan(Long value) { + addCriterion("coupon_code_id <", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdLessThanOrEqualTo(Long value) { + addCriterion("coupon_code_id <=", value, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdIn(List values) { + addCriterion("coupon_code_id in", values, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotIn(List values) { + addCriterion("coupon_code_id not in", values, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdBetween(Long value1, Long value2) { + addCriterion("coupon_code_id between", value1, value2, "couponCodeId"); + return (Criteria) this; + } + + public Criteria andCouponCodeIdNotBetween(Long value1, Long value2) { + addCriterion("coupon_code_id not between", value1, value2, "couponCodeId"); return (Criteria) this; } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java index 78f33d29..57d98c69 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRel.java @@ -21,6 +21,11 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria */ private Long id; + /** + * 类型 1:销售码 2:兑换码 + */ + private Integer type; + /** * 卡券名称 */ @@ -87,6 +92,14 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria this.id = id; } + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + public String getCouponName() { return couponName; } @@ -204,6 +217,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria } HighCouponAgentRel other = (HighCouponAgentRel) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) && (this.getCouponName() == null ? other.getCouponName() == null : this.getCouponName().equals(other.getCouponName())) && (this.getSalesPrice() == null ? other.getSalesPrice() == null : this.getSalesPrice().equals(other.getSalesPrice())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) @@ -224,6 +238,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria final int prime = 31; int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); result = prime * result + ((getCouponName() == null) ? 0 : getCouponName().hashCode()); result = prime * result + ((getSalesPrice() == null) ? 0 : getSalesPrice().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); @@ -247,6 +262,7 @@ public class HighCouponAgentRel extends HighCouponAgentRelModel implements Seria sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", type=").append(type); sb.append(", couponName=").append(couponName); sb.append(", salesPrice=").append(salesPrice); sb.append(", couponId=").append(couponId); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java index 3d82ecff..59ebd92c 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentRelExample.java @@ -186,6 +186,66 @@ public class HighCouponAgentRelExample { return (Criteria) this; } + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + public Criteria andCouponNameIsNull() { addCriterion("coupon_name is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java b/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java index 8c9cd0ac..0eca04ca 100644 --- a/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java +++ b/hai-service/src/main/java/com/hai/model/HighCouponAgentRelModel.java @@ -3,6 +3,8 @@ package com.hai.model; import com.hai.entity.HighAgent; import com.hai.entity.HighCoupon; +import java.math.BigDecimal; + /** * @Auther: 胡锐 * @Description: @@ -18,6 +20,18 @@ public class HighCouponAgentRelModel { //代理商信息 private HighAgent highAgent; + // 未使用数量 + private Integer noUsedNum; + + // 未使用金额 + private BigDecimal noUsedPrice; + + // 使用数量 + private Integer usedNum; + + // 使用金额 + private BigDecimal usedPrice; + public String getMerchantLogo() { return merchantLogo; } @@ -41,4 +55,36 @@ public class HighCouponAgentRelModel { public void setHighAgent(HighAgent highAgent) { this.highAgent = highAgent; } + + public Integer getNoUsedNum() { + return noUsedNum; + } + + public void setNoUsedNum(Integer noUsedNum) { + this.noUsedNum = noUsedNum; + } + + public BigDecimal getNoUsedPrice() { + return noUsedPrice; + } + + public void setNoUsedPrice(BigDecimal noUsedPrice) { + this.noUsedPrice = noUsedPrice; + } + + public Integer getUsedNum() { + return usedNum; + } + + public void setUsedNum(Integer usedNum) { + this.usedNum = usedNum; + } + + public BigDecimal getUsedPrice() { + return usedPrice; + } + + public void setUsedPrice(BigDecimal usedPrice) { + this.usedPrice = usedPrice; + } } diff --git a/hai-service/src/main/java/com/hai/service/CmsContentService.java b/hai-service/src/main/java/com/hai/service/CmsContentService.java index 47a64f8d..2f7e7c43 100644 --- a/hai-service/src/main/java/com/hai/service/CmsContentService.java +++ b/hai-service/src/main/java/com/hai/service/CmsContentService.java @@ -85,6 +85,19 @@ public interface CmsContentService { */ List getListContent(Map paramsMap) throws Exception; + + /** + * + * @Title: getListContent + * @Description: 查询内容列表 + * @author: gongjia + * @param: [paramsMap] + * @return: java.util.List + * @throws + */ + List getListContentByCrest(Map paramsMap) throws Exception; + + /** * * @Title: getCorporateAdvertising diff --git a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java index 60f1f27b..052070db 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java @@ -35,7 +35,7 @@ public interface HighCouponAgentService { * @Description 根据卡券id和代理商id 查询 * @Date 2021/4/20 23:52 **/ - HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId); + HighCouponAgentRel getRelByCouponAgent(Long couponId,Long agentId, Integer type); /** * @Author 胡锐 @@ -78,7 +78,9 @@ public interface HighCouponAgentService { * @Description 根据代理商 查询销售统计 * @Date 2021/4/22 22:26 **/ - Map getSalesCountByAgent(Long agentId) throws Exception; + Map getSalesCountByAgent(Long agentId, Integer type) throws Exception; + + Map getConvertCodeCountByAgent(Long agentId); /** * @@ -104,4 +106,25 @@ public interface HighCouponAgentService { */ List getAgentSalesCodeList(Long agentId,String consumeTimeS,String consumeTimeE); + /** + * 生成兑换码 + * @param couponAgentRelId + * @return + */ + String generateConvertCode(Long couponAgentRelId); + + /** + * 查询兑换码 + * @param convertCode + * @return + */ + HighCouponAgentCode getConvertCode(String convertCode); + + /** + * 使用兑换码 + * @param code + * @return + */ + Map useConvertCode(String code); + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java index 7fe0e5c5..e22d3382 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java @@ -89,4 +89,14 @@ public interface HighDiscountPackageService { */ void addDiscountPackageStock(HighDiscountPackage highDiscountPackage, UserInfoModel userInfoModel , Integer num); + /** + * @Author Sum1Dream + * @name freeUserDiscountPackage.java + * @Description // 赠送用户优惠券包内容 + * @Date 3:09 下午 2021/12/24 + * @Param [java.lang.Long] + * @return void + */ + void freeUserDiscountPackage(Map map) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountService.java b/hai-service/src/main/java/com/hai/service/HighDiscountService.java index 7f60ae30..8661c42b 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountService.java @@ -39,5 +39,6 @@ public interface HighDiscountService { * @Date 2021/4/3 21:39 **/ List getDiscount(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/HighTestService.java b/hai-service/src/main/java/com/hai/service/HighTestService.java new file mode 100644 index 00000000..c1ae0656 --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighTestService.java @@ -0,0 +1,33 @@ +package com.hai.service; + +/** + * @serviceName HltMerchantService.java + * @author Sum1Dream + * @version 1.0.0 + * @Description // 测试接口 + * @createTime 11:46 上午 2021/12/15 + **/ +public interface HighTestService { + + /** + * @Author Sum1Dream + * @name getReadFile.java + * @Description //读取文件 + * @Date 5:31 下午 2021/12/16 + * @Param [] + * @return void + */ + void getReadFile() throws Exception; + + + /** + * @Author Sum1Dream + * @name getUserDiscount.java + * @Description // 赠送用户卡券 + * @Date 7:14 下午 2021/12/24 + * @Param [] + * @return void + */ + void getUserDiscount(Long id) throws Exception; + +} diff --git a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java index f7a883eb..2dac374a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CmsContentServiceImpl.java @@ -178,6 +178,11 @@ public class CmsContentServiceImpl implements CmsContentService { return cmsContentMapper.getListContent(paramsMap); } + @Override + public List getListContentByCrest(Map paramsMap) throws Exception { + return cmsContentMapper.getListContentByCrest(paramsMap); + } + @Override public List getCorporateAdvertising() { CmsContentExample example = new CmsContentExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 885d53b0..346fdd80 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -1,6 +1,7 @@ package com.hai.service.impl; import com.github.pagehelper.PageInfo; +import com.hai.common.GenerateCode; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -15,6 +16,7 @@ import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -54,13 +56,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { private HighAgentService highAgentService; @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) { - // 查询未销售的卡券 - List codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId()); - if (stockCount > codeList.size()) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量"); - } if (highCouponAgentRel.getId() != null) { highCouponAgentRelMapper.updateByPrimaryKey(highCouponAgentRel); } else { @@ -87,26 +85,52 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { record.setCreateTime(new Date()); highCouponAgentRecordMapper.insert(record); - List assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList()); - HighCouponAgentCode highCouponAgentCode; - for (HighCouponCode code : assignCouponCodeList) { - code.setAgentId(highCouponAgentRel.getAgentId()); - code.setIsAssignAgent(true); - highCouponCodeService.updateCouponCode(code); - - highCouponAgentCode = new HighCouponAgentCode(); - highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); - highCouponAgentCode.setCouponAgentRecordId(record.getId()); - highCouponAgentCode.setCouponId(code.getCouponId()); - highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); - highCouponAgentCode.setCouponCodeId(code.getId()); - highCouponAgentCode.setCouponCode(code.getSalesCode()); - highCouponAgentCode.setQrCode(code.getExt1()); - highCouponAgentCode.setStatus(1); - highCouponAgentCode.setCreateTime(new Date()); - highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); - highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); - highCouponAgentCodeMapper.insert(highCouponAgentCode); + if (highCouponAgentRel.getType() == 1) { + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(highCouponAgentRel.getCouponId()); + if (stockCount > codeList.size()) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法分配,分配数量超过库存数量"); + } + List assignCouponCodeList = codeList.stream().limit(stockCount).collect(Collectors.toList()); + HighCouponAgentCode highCouponAgentCode; + for (HighCouponCode code : assignCouponCodeList) { + code.setAgentId(highCouponAgentRel.getAgentId()); + code.setIsAssignAgent(true); + highCouponCodeService.updateCouponCode(code); + + highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setType(highCouponAgentRel.getType()); + highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); + highCouponAgentCode.setCouponAgentRecordId(record.getId()); + highCouponAgentCode.setCouponId(code.getCouponId()); + highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); + highCouponAgentCode.setCouponCodeId(code.getId()); + highCouponAgentCode.setCouponCode(code.getSalesCode()); + highCouponAgentCode.setQrCode(code.getExt1()); + highCouponAgentCode.setStatus(1); + highCouponAgentCode.setCreateTime(new Date()); + highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); + highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); + highCouponAgentCodeMapper.insert(highCouponAgentCode); + } + } + + if (highCouponAgentRel.getType() == 2) { + HighCouponAgentCode highCouponAgentCode; + for (int i = 0; i < stockCount; i++) { + highCouponAgentCode = new HighCouponAgentCode(); + highCouponAgentCode.setType(highCouponAgentRel.getType()); + highCouponAgentCode.setCouponAgentId(highCouponAgentRel.getId()); + highCouponAgentCode.setCouponAgentRecordId(record.getId()); + highCouponAgentCode.setCouponId(highCoupon.getId()); + highCouponAgentCode.setAgentId(highCouponAgentRel.getAgentId()); + highCouponAgentCode.setConvertCode(generateConvertCode(highCouponAgentRel.getId())); + highCouponAgentCode.setStatus(1); + highCouponAgentCode.setCreateTime(new Date()); + highCouponAgentCode.setOperatorId(highCouponAgentRel.getOperatorId()); + highCouponAgentCode.setOperatorName(highCouponAgentRel.getOperatorName()); + highCouponAgentCodeMapper.insert(highCouponAgentCode); + } } } @@ -116,9 +140,9 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } @Override - public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId) { + public HighCouponAgentRel getRelByCouponAgent(Long couponId, Long agentId,Integer type) { HighCouponAgentRelExample example = new HighCouponAgentRelExample(); - example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId); + example.createCriteria().andCouponIdEqualTo(couponId).andAgentIdEqualTo(agentId).andTypeEqualTo(type); List list = highCouponAgentRelMapper.selectByExample(example); if (list != null && list.size() > 0) { return list.get(0); @@ -131,6 +155,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { HighCouponAgentRelExample example = new HighCouponAgentRelExample(); HighCouponAgentRelExample.Criteria criteria = example.createCriteria(); + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + if (MapUtils.getLong(map, "couponId") != null) { criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); } @@ -153,6 +181,10 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { criteria.andCouponAgentIdEqualTo(MapUtils.getLong(map, "couponAgentId")); } + if (MapUtils.getInteger(map, "type") != null) { + criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); + } + if (MapUtils.getLong(map, "couponId") != null) { criteria.andCouponIdEqualTo(MapUtils.getLong(map, "couponId")); } @@ -213,15 +245,19 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { couponAgentCode.setRemark(remark); highCouponAgentCodeMapper.updateByPrimaryKey(couponAgentCode); - HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId()); + HighCouponAgentRel couponAgent = getRelByCouponAgent(couponAgentCode.getCouponId(), couponAgentCode.getAgentId(), couponAgentCode.getType()); couponAgent.setStockCount(couponAgent.getStockCount() - 1); couponAgent.setSalesCount(couponAgent.getSalesCount() + 1); highCouponAgentRelMapper.updateByPrimaryKey(couponAgent); - HighCouponCode couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); - couponCode.setStatus(2); - couponCode.setReceiveTime(new Date()); - highCouponCodeService.updateCouponCode(couponCode); + + HighCouponCode couponCode = null; + if (couponAgentCode.getType() == 1) { + couponCode = highCouponCodeService.getCouponCodeById(couponAgentCode.getCouponCodeId()); + couponCode.setStatus(2); + couponCode.setReceiveTime(new Date()); + highCouponCodeService.updateCouponCode(couponCode); + } Map map = new HashMap<>(); map.put("couponInfo", highCouponService.getCouponById(couponAgentCode.getCouponId())); @@ -231,12 +267,13 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } @Override - public Map getSalesCountByAgent(Long agentId) throws Exception { + public Map getSalesCountByAgent(Long agentId, Integer type) throws Exception { BigDecimal surplusCountPrice = new BigDecimal("0"); BigDecimal salesCountPrice = new BigDecimal("0"); Map listMap = new HashMap<>(); listMap.put("agentId", agentId); + listMap.put("type", type); List list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); for (HighCouponAgentRel highCouponAgentRel : list) { BigDecimal surplusPrice = new BigDecimal(highCouponAgentRel.getStockCount()).multiply((highCouponAgentRel.getSalesPrice())); @@ -246,7 +283,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { salesCountPrice = salesCountPrice.add(salesPrice); } - // 计算使用有效期 + // 当前日时间 Calendar consumeTimeS = Calendar.getInstance(); consumeTimeS.setTime(new Date()); consumeTimeS.set(Calendar.HOUR_OF_DAY, 00); @@ -265,8 +302,8 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { returnMap.put("orderCount", agentSales.getCount()); returnMap.put("turnoverPrice", agentSales.getSalesCountPrice()); - returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1")); // 库存数量 - returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3")); // 销售数量 + returnMap.put("laveStockCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1", type)); // 库存数量 + returnMap.put("soldCount", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2,3", type)); // 销售数量 returnMap.put("surplusCountPrice", surplusCountPrice); // 剩余总额 returnMap.put("salesCountPrice", salesCountPrice); // 销售总额 @@ -274,6 +311,43 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { return returnMap; } + @Override + public Map getConvertCodeCountByAgent(Long agentId) { + Map listMap = new HashMap<>(); + listMap.put("agentId", agentId); + listMap.put("type", 2); + List list = getCouponAgentList(listMap).stream().sorted(Comparator.comparing(HighCouponAgentRel::getSalesPrice)).collect(Collectors.toList()); + + for (HighCouponAgentRel couponAgentRel : list) { + Map map = highCouponAgentRelMapper.getUseNum(couponAgentRel.getId()); + couponAgentRel.setUsedNum(MapUtils.getInteger(map, "usedNum")); + couponAgentRel.setUsedPrice(new BigDecimal(MapUtils.getString(map, "usedPrice"))); + couponAgentRel.setNoUsedNum(MapUtils.getInteger(map, "noUsedNum")); + couponAgentRel.setNoUsedPrice(new BigDecimal(MapUtils.getString(map, "noUsedPrice"))); + } + + Map returnMap = new HashMap<>(); + returnMap.put("list", list); + + // 待销售 + returnMap.put("noSalesNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "1", 2)); + returnMap.put("noSalesPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "1", 2)); + + // 已销售 + returnMap.put("salesNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2", 2)); + returnMap.put("salesPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "2", 2)); + + // 待使用 + returnMap.put("noUsedNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "2", 2)); + returnMap.put("noUsedPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "2", 2)); + + // 已使用 + returnMap.put("usedNum", highCouponAgentRelMapper.getAgentCodeCount(agentId, "3", 2)); + returnMap.put("usedPrice", highCouponAgentRelMapper.getAgentCodePrice(agentId, "3", 2)); + + return returnMap; + } + @Override public List getRecordList(Map map) { HighCouponAgentRecordExample example = new HighCouponAgentRecordExample(); @@ -312,4 +386,65 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { } return new ArrayList<>(); } + + @Override + public String generateConvertCode(Long couponAgentRelId) { + // 生成兑换码 + String code = GenerateCode.convertCode(couponAgentRelId); + if (getConvertCode(code) != null){ + return generateConvertCode(couponAgentRelId); + } + return code; + } + + @Override + public HighCouponAgentCode getConvertCode(String convertCode) { + HighCouponAgentCodeExample example = new HighCouponAgentCodeExample(); + example.createCriteria().andConvertCodeEqualTo(convertCode); + List list = highCouponAgentCodeMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) + public Map useConvertCode(String code) { + // 查询兑换码 + HighCouponAgentCode convertCode = getConvertCode(code); + if (convertCode == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的兑换码"); + } + if (convertCode.getStatus() == 3) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + if (convertCode.getCouponCodeId() != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); + } + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId()); + if (codeList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码"); + } + HighCouponCode couponCode = codeList.get(0); + couponCode.setIsAssignAgent(true); + couponCode.setAgentId(couponCode.getAgentId()); + couponCode.setReceiveTime(new Date()); + couponCode.setStatus(2); + highCouponCodeService.updateCouponCode(couponCode); + + convertCode.setCouponCodeId(couponCode.getId()); + convertCode.setCouponCode(couponCode.getSalesCode()); + convertCode.setQrCode(couponCode.getExt1()); + convertCode.setStatus(3); + highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); + + // 查询卡券销售码 + Map map = new HashMap<>(); + map.put("couponInfo", highCouponService.getCouponById(convertCode.getCouponId())); + map.put("couponCode", highCouponCodeService.getCouponCodeById(convertCode.getCouponCodeId())); + map.put("couponAgentCode", convertCode); + return map; + } } 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 bb336378..5a0f38e6 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 @@ -3,12 +3,16 @@ package com.hai.service.impl; 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.RedisUtil; import com.hai.dao.*; import com.hai.entity.*; import com.hai.model.UserInfoModel; import com.hai.service.*; import com.hai.service.HighDiscountPackageService; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -52,6 +56,28 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Resource private HighDiscountInventoryRecordMapper discountInventoryRecordMapper; + @Resource + private HighUserService highUserService; + + @Resource + private HighDiscountPackageService highDiscountPackageService; + + + @Resource + private HighDiscountUserRelMapper highDiscountUserRelMapper; + + @Resource + private HighDiscountService highDiscountService; + + @Resource + private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; + + @Autowired + private RedisUtil redisUtil; + @Override public List getDiscountPackageList(Map map) { @@ -223,4 +249,75 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic highDiscountPackageMapper.updateByPrimaryKey(highDiscountPackage); } + + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void freeUserDiscountPackage(Map map) throws Exception { + + + HighDiscountPackage highDiscountPackage = highDiscountPackageService.findDiscountPackageById(MapUtils.getInteger(map , "discountPackageId")); + + + // 查询优惠券包实际库存 + HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0); + + // 修改优惠券包实际库存为已使用 + discountPackageActual.setStatus(0); + discountPackageActual.setUserId(MapUtils.getInteger(map , "userId")); + discountPackageActual.setAllocationTime(new Date()); + discountPackageActualService.updateHighDiscountPackageActual(discountPackageActual); + + // 查询优惠券包实际库存中实际优惠券数量 + List discountPackageDiscountActual = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(discountPackageActual.getId()); + + // 循环赠送优惠券 + for (HighDiscountPackageDiscountActual actualList: discountPackageDiscountActual) { + + HighDiscountUserRel highDiscountUserRel = new HighDiscountUserRel(); + highDiscountUserRel.setDiscountId(actualList.getDiscountId()); + highDiscountUserRel.setUserId(MapUtils.getLong(map , "userId")); + highDiscountUserRel.setAgentId(actualList.getAgentId()); + highDiscountUserRel.setDiscountAgentCodeId(actualList.getAgentDiscountCodeId()); + highDiscountUserRel.setStatus(1); + highDiscountUserRel.setCreateTime(new Date()); + + HighDiscount highDiscount = highDiscountService.getDiscountById(actualList.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()); + + HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(actualList.getAgentDiscountCodeId()); + + // 修改优惠券二维码状态 + discountAgentCode.setStatus(2); + highDiscountAgentCodeService.updateCode(discountAgentCode); + + // 新增优惠券与用户的绑定关系 + highDiscountUserRelMapper.insert(highDiscountUserRel); + + // 修改优惠券包实际库存实际优惠券状态 + actualList.setStatus(0); + discountPackageDiscountActualService.updateHighDiscountPackageDiscountActual(actualList); + } + + // 增加赠送记录 + 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(MapUtils.getInteger(map , "userId")); + discountPackageRecord.setExt1(MapUtils.getString(map , "userPhone")); + discountPackageRecord.setCreatedTime(new Date()); + highDiscountPackageRecordMapper.insert(discountPackageRecord); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 98456083..a0d2571d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -210,7 +210,7 @@ public class HighOrderServiceImpl implements HighOrderService { HighUser highUser = highUserService.findByUserId(highOrder.getMemId()); // 金币 1:100 - Integer goldNum = new BigDecimal(highOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); + Integer goldNum = new BigDecimal(highOrder.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue(); highUserService.goldHandle(userId, goldNum, 2, 2, highOrder.getId()); highOrder.setPayTime(new Date()); // 支付时间 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java new file mode 100644 index 00000000..c2d2d96b --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java @@ -0,0 +1,136 @@ +package com.hai.service.impl; + + +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.utils.RedisUtil; +import com.hai.dao.HighUserEtcMapper; +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighUser; +import com.hai.entity.HighUserEtc; +import com.hai.service.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service("highTestService") +public class HighTestServiceImpl implements HighTestService { + + private static Logger log = LoggerFactory.getLogger(HighTestService.class); + + @Resource + private HighUserService highUserService; + + @Resource + private HighUserEtcMapper highUserEtcMapper; + + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Autowired + private RedisUtil redisUtil; + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getReadFile() throws Exception { +// BufferedReader bufferedReader = null; +// +// Map mapUser = new HashMap<>(); +// +// //cookie过期时间为7天 +// int EXPIRE = 3600*24*7; +// +// List highUsers = highUserService.getListUser(mapUser); +// +// for (HighUser user: highUsers) { +// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE); +// } +// +// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt"); +// if (fileReader == null) { +// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据"); +// } +// +// bufferedReader = new BufferedReader(fileReader); +// String temp = bufferedReader.readLine(); +// int i = 0; +// while (temp != null) { +// i++; +// String[] arr = temp.split(";"); +// +// String phone = (String) redisUtil.get(arr[3]); +// +// if (phone == null || highUsers.size() == 0) { +// HighUser user = new HighUser(); +// +// user.setStatus(1); +// user.setInfoCompleteStatus(1); +// user.setGold(0); +// user.setRegTime(new Date()); +// user.setName(arr[2]); +// user.setPhone(arr[3]); +// user.setExt4("1"); +// +// highUserService.insertUser(user); +// +// HighUserEtc userEtc = new HighUserEtc(); +// +// userEtc.setCreateTime(new Date()); +// userEtc.setStatus(1); +// userEtc.setUserId(user.getId()); +// userEtc.setCustomerName(arr[2]); +// userEtc.setCustomerTel(arr[3]); +// userEtc.setVehicleId(arr[0]); +// userEtc.setVehiclePlate(arr[1]); +// +// highUserEtcMapper.insert(userEtc); +// +//// Map map = new HashMap<>(); +//// map.put("userId" , user.getId()); +//// map.put("userPhone" , user.getPhone()); +//// map.put("discountPackageId" , 48); +// +//// highDiscountPackageService.freeUserDiscountPackage(map); +// } +// +// temp = bufferedReader.readLine(); +// } + } + + @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) + public void getUserDiscount(Long id) throws Exception{ + List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1); + Map map = new HashMap<>(); + map.put("ext4" , "1"); + List userList = highUserService.getListUser(map); + + int num = 0; + for (HighUser user : userList) { + // 领取优惠券 + highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId()); + num++; + } + } +} 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 cb7ff1c5..a50755da 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 @@ -65,6 +65,9 @@ public class HighUserServiceImpl implements HighUserService { if (StringUtils.isNotBlank(map.get("status"))) { criteria.andStatusEqualTo(Integer.valueOf(map.get("status"))); } + if (StringUtils.isNotBlank(map.get("ext4"))) { + criteria.andExt4EqualTo(String.valueOf(map.get("ext4"))); + } if (StringUtils.isNotBlank(map.get("regTimeStart")) && StringUtils.isNotBlank(map.get("regTimeEnd"))) { criteria.andRegTimeBetween( DateUtil.format(map.get("regTimeStart") , "yyyy-MM-dd HH:mm:ss") , diff --git a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java index 872eecba..735e832b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HltUnionCardVipServiceImpl.java @@ -116,8 +116,6 @@ public class HltUnionCardVipServiceImpl implements HltUnionCardVipService { HighDiscountPackage highDiscountPackage = highDiscountPackages.get(0); - highDiscountPackageService.updateDiscountPackage(highDiscountPackage); - // 查询优惠券包实际库存 HighDiscountPackageActual discountPackageActual = discountPackageActualService.getHighDiscountPackageActualList(highDiscountPackage.getId()).get(0); diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java index eb310bd5..5392cc6b 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java @@ -46,6 +46,9 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService { if (StringUtils.isNotBlank(map.get("type"))) { criteria.andTypeEqualTo(Integer.valueOf(map.get("type"))); } + if (StringUtils.isNotBlank(map.get("showType"))) { + criteria.andShowTypeEqualTo(Integer.valueOf(map.get("showType"))); + } if (StringUtils.isNotBlank(map.get("companyId"))) { criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index c3a0925f..04df7221 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.hai.service.pay.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; @@ -10,6 +11,7 @@ import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.WxUtils; import com.hai.config.CommonSysConst; import com.hai.config.HuiLianTongConfig; +import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.TuanYouConfig; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighDiscountPackageRecordMapper; @@ -259,6 +261,8 @@ public class GoodsOrderServiceImpl implements PayService { if (highChildOrder.getGoodsType() == 2) { highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + order.setFinishTime(new Date()); + order.setOrderStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 金币 1:100 Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId()); @@ -327,6 +331,51 @@ public class GoodsOrderServiceImpl implements PayService { discountPackageActualService.updateHighDiscountPackageActual(actual); } } + + if (highChildOrder.getGoodsType() == 8) { + // 汇联通充值 + String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; + String tranDesc = ""; + String businessType = "ghk_deposit"; + + // 汇联通卡充值 + JSONObject deposit = HuiLianTongUnionCardConfig.deposit(order.getOrderNo(), order.getMemCardNo(), order.getPayPrice(), businessType, map.get("transaction_id"), tranDesc); + System.out.println("工会卡支付响应参数" + deposit.toJSONString()); + + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data")); + + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", order.getOrderNo()); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", order.getMemCardNo()); + dataMap.put("checkPassword", "N"); + dataMap.put("tranAmount", order.getPayPrice()); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("goodsDesc", goodsDesc); + dataMap.put("tranDesc", tranDesc); + HighGasOrderPush payPush = new HighGasOrderPush(); + payPush.setType(OrderPushType.type5.getType()); + payPush.setOrderNo(order.getOrderNo()); + payPush.setCreateTime(new Date()); + payPush.setCode(deposit.getString("respCode")); + payPush.setRequestContent(JSON.toJSONString(dataMap)); + payPush.setReturnContent(deposit.toJSONString()); + highGasOrderPushMapper.insert(payPush); + + if (!Objects.equals(deposit.getString("respCode"), "0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , deposit.getString("respMessage")); + } + // 记录回调信息 + if (!dataObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); + } + + // 修改订单状态 + highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + order.setFinishTime(new Date()); + order.setOrderStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + } } highOrderService.updateOrder(order);