diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java index 60888e09..dd2aeb64 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -195,6 +195,7 @@ public class HighDiscountAgentRelController { } } + @RequestMapping(value="/getDiscountCodeList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询优惠券码 列表") diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java index ffcd1c9d..0a67722b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java @@ -10,9 +10,11 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighDiscount; +import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; import com.hai.service.HighDiscountService; +import com.hai.service.HighDiscountUserRelService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -46,6 +48,8 @@ public class HighDiscountController { @Resource private HighDiscountService highDiscountService; + @Resource + private HighDiscountUserRelService discountUserRelService; @RequestMapping(value="/insertDiscount",method = RequestMethod.POST) @ResponseBody @@ -234,4 +238,33 @@ public class HighDiscountController { } } + @RequestMapping(value="/getAgentDiscountList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询代理商优惠券列表") + public ResponseData getAgentDiscountList(@RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "discountName", required = false) String discountName, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getHighAgent() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); + } + + Map param = new HashMap<>(); + param.put("ext1", userInfoModel.getHighAgent().getId()); + param.put("discountName", discountName); + param.put("status", status); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(discountUserRelService.getDiscountList(param))); + + } catch (Exception e) { + log.error("HighDiscountController -> getUserDiscountList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } 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 2279fb54..9f2a80a1 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -102,6 +102,8 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/discount/getCouponByDiscount") .excludePathPatterns("/discountPackage/getDiscountPackageList") .excludePathPatterns("/discountPackage/getDiscountPackageDetail") + .excludePathPatterns("/discountPackage/receivePackageTemporary") + .excludePathPatterns("/discountPackage/getDiscountPackageCode") .excludePathPatterns("/discount/getDiscountByDiscountAgentId") .excludePathPatterns("/highMerchantStore/getMerchantStoreById") .excludePathPatterns("/highMerchantStore/getStoreListByCoupon") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountPackageController.java b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountPackageController.java index b1d98c34..0a4e822b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountPackageController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountPackageController.java @@ -15,7 +15,6 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; -import com.hai.model.UserInfoModel; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -23,6 +22,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -50,6 +50,22 @@ public class HighDiscountPackageController { @Resource private CommonService commonService; + @Resource + private HighDiscountPackageAgentService discountPackageAgentService; + + @Resource + private BsTemporaryServices bsTemporaryServices; + + @Autowired + private RedisTemplate redisTemplate; + + @Resource + private UserCenter userCenter; + + @Resource + private HighUserService userService; + + @RequestMapping(value = "/getDiscountPackageList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取优惠券包列表") @@ -106,11 +122,135 @@ public class HighDiscountPackageController { } } + + @RequestMapping(value = "/receivePackageTemporary", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "券包临时领取") + public ResponseData receivePackageTemporary(@RequestParam(name = "packageId", required = true) Integer packageId, + @RequestParam(name = "openId", required = true) String openId, + @RequestParam(name = "agentId", required = true) Long agentId) { + + String key = "receivePackage_" + packageId + "_" + agentId; + + Map param = new HashMap<>(); + param.put("openIdH5", openId); + List userList = userService.getUserList(param); + + + try { + // 分布式锁占坑 + Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, openId); + + if (Boolean.TRUE.equals(lock)) { + + Map map = new HashMap<>(); + map.put("agentId" , agentId); + map.put("discountPackageId" , packageId); + map.put("status" , 1); + + List list = discountPackageAgentService.getDiscountPackageAgentCodeList(map); + + if (list.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未查询当相关内容!"); + } + + HighDiscountPackageAgentCode discountPackageAgentCode = list.get(0); + + if (list.size() == 0) { + log.error("HighDiscountController -> getDiscountByQrCode() error!","当前券包库存不足"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前券包库存不足"); + } + + BsTemporary bsTemporary = bsTemporaryServices.findByCode(openId , 7); + + if (bsTemporary != null) { + if (userList.size() > 0) { + HighUser user = userList.get(0); + if (StringUtils.isNotBlank(user.getPhone())) { + highDiscountPackageService.decodeCode(bsTemporary.getCode() , user); + return ResponseMsgUtil.success("领取成功!"); + } + } + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "今日已领取,请尽快使用!"); + } + + if (userList.size() > 0) { + HighUser user = userList.get(0); + if (StringUtils.isNotBlank(user.getPhone())) { + highDiscountPackageService.decodeCode(discountPackageAgentCode.getCode() , user); + return ResponseMsgUtil.success("领取成功!"); + } + } + + bsTemporary = new BsTemporary(); + bsTemporary.setCode(discountPackageAgentCode.getCode()); + bsTemporary.setCreateTime(new Date()); + bsTemporary.setUpdateTime(new Date()); + bsTemporary.setSourceCode(openId); + bsTemporary.setStatus(1); + bsTemporary.setType(7); + bsTemporaryServices.insert(bsTemporary); + + discountPackageAgentCode.setStatus(5); + discountPackageAgentCode.setUpdateTime(new Date()); + discountPackageAgentService.updateDiscountPackageAgentCode(discountPackageAgentCode); + + } else { + // 加锁失败,重试 + Thread.sleep(100); + receivePackageTemporary(packageId , openId , agentId); + } + return ResponseMsgUtil.success("领取成功!"); + + } catch (Exception e) { + log.error("HighDiscountPackageController --> getDiscountPackageDetail() error!", e); + return ResponseMsgUtil.exception(e); + } finally { + // 删除key,释放锁 + redisTemplate.delete(key); + } + } + + @RequestMapping(value = "/test", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "test") + public ResponseData test() { + try { + // 用户 + List list = bsTemporaryServices.getList(new HashMap<>()); + + for (BsTemporary bsTemporary : list) { + + HighDiscountPackageAgentCode discountPackageAgentCode = discountPackageAgentService.findDiscountPackageAgentCode(bsTemporary.getCode()); + discountPackageAgentCode.setStatus(1); + discountPackageAgentCode.setUpdateTime(new Date()); + discountPackageAgentService.updateDiscountPackageAgentCode(discountPackageAgentCode); + bsTemporary.setStatus(0); + bsTemporary.setUpdateTime(new Date()); + bsTemporaryServices.update(bsTemporary); + + } + + return ResponseMsgUtil.success("成功!"); + + } catch (Exception e) { + log.error("HighDiscountPackageController --> giveAway() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/receivePackage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "领取券包") - public ResponseData receivePackage(@RequestParam(name = "code", required = false) String code) { + public ResponseData receivePackage(@RequestParam(name = "code", required = false) String code, HttpServletRequest request) { try { + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + // 用户 String jsonData; try { @@ -127,8 +267,11 @@ public class HighDiscountPackageController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前业务不支持!"); } + JSONObject object = new JSONObject(); + object.put("code" , code); + object.put("discountPackageActualId" , jsonObject.getInteger("id")); - highDiscountPackageService.receivePackage(jsonObject.getInteger("id") , code); + highDiscountPackageService.receivePackage(object , userInfoModel.getHighUser()); return ResponseMsgUtil.success("领取成功!"); diff --git a/hai-order/src/main/java/com/web/controller/business/ApiMerOrderController.java b/hai-order/src/main/java/com/web/controller/business/ApiMerOrderController.java new file mode 100644 index 00000000..7063253d --- /dev/null +++ b/hai-order/src/main/java/com/web/controller/business/ApiMerOrderController.java @@ -0,0 +1,105 @@ +package com.web.controller.business; + +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.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.enum_type.UserObjectTypeEnum; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.order.service.OrderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "apiMerOrder") +@Api(value = "接口商户订单业务") +public class ApiMerOrderController { + + private static Logger log = LoggerFactory.getLogger(OrderThirdPartyController.class); + + @Resource + private UserCenter userCenter; + + @Resource + private OrderService orderService; + + + @RequestMapping(value = "/getOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询api商户订单列表") + public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "memPhone", required = false) String memPhone, + @RequestParam(name = "memCardNo", required = false) String memCardNo, + @RequestParam(name = "payType", required = false) Integer payType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "companyId", required = false) Long companyId, + @RequestParam(name = "promoteCode", required = false) Long promoteCode, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "finishTimeS", required = false) Long finishTimeS, + @RequestParam(name = "finishTimeE", required = false) Long finishTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + Map map = new HashMap<>(); + + map.put("createTimeS", createTimeS); + map.put("createTimeE", createTimeE); + map.put("payTimeS", payTimeS); + map.put("payTimeE", payTimeE); + map.put("finishTimeS", finishTimeS); + map.put("finishTimeE", finishTimeE); + map.put("orderNo", orderNo); + map.put("memPhone", memPhone); + map.put("memCardNo", memCardNo); + map.put("productType", productType); + map.put("status", status); + map.put("payType", payType); + map.put("promoteCode", promoteCode); + + PageHelper.startPage(pageNum,pageSize); + return ResponseMsgUtil.success(new PageInfo<>(orderService.getOrderList(map))); + + } catch (Exception e) { + log.error("OrderCouponController --> getOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getOrderDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询订单详情") + public ResponseData getOrderDetail(@RequestParam(name = "orderNo", required = true) String orderNo) { + try { + Map map = new HashMap<>(); + map.put("tradeOrder", orderService.getOrderDetailByNo(orderNo)); + + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("OrderIntegralRechargeController -> getOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountPackageActualMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighDiscountPackageActualMapperExt.java index f5a28145..b033d5d9 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountPackageActualMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountPackageActualMapperExt.java @@ -1,7 +1,28 @@ package com.hai.dao; +import com.hai.entity.HighCouponAgentCode; +import com.hai.entity.HighDiscountPackageActual; +import com.hai.entity.HighDiscountPackageRecord; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Result; +import org.apache.ibatis.annotations.Results; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.type.JdbcType; + +import java.util.List; + /** * mapper扩展类 */ public interface HighDiscountPackageActualMapperExt { + @Select( + " SELECT *" + + " FROM high_discount_package_actual" + + " WHERE" + + " status = 3 " + + " AND allocation_time >= DATE_SUB(CURRENT_TIMESTAMP(), INTERVAL #{day} DAY) " + + " AND user_id = #{userId} " + + " AND discount_package_id = #{discountPackageId}; " + ) + List receivePackageLimit(@Param("userId") Integer userId, @Param("discountPackageId") Integer discountPackageId, @Param("day") Integer day); } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java index 222ce52e..f6b742a1 100644 --- a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java @@ -490,7 +490,11 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ // 查询api商户 ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); - ApiCoupon apiCoupon = apiCouponService.findCoupon(dataObject.getString("code")); + ApiCoupon apiCoupon = apiCouponService.findCoupon(dataObject.getString("couponCode")); + + if (apiCoupon == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前卡券已停用!"); + } // 查询折扣比例 Map mapProduct = new HashMap<>(); @@ -518,7 +522,7 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ ApiOrder apiOrder = new ApiOrder(); apiOrder.setCreateTime(new Date()); apiOrder.setTitle(apiMerchants.getMerchantName() + "|" + OrderProductType.PRODUCT_TYPE18.getName() + "|扣款" + price); - apiOrder.setFacePrice(new BigDecimal(apiCoupon.getPrice())); + apiOrder.setFacePrice(new BigDecimal(apiCoupon.getPrice()/100)); apiOrder.setCostPrice(price); apiOrder.setOrderPrice(price); apiOrder.setMchId(object.getString("merchId")); diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java index 5dee7a25..4c7b3eba 100644 --- a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java @@ -281,6 +281,7 @@ public class ApiOrderServiceImpl implements ApiOrderService { createOrderChildModel.setSaleCount(1); createOrderChildModel.setIsTyAgent(false); createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice()); + createOrderChildModel.setPrice(apiOrder.getCostPrice()); // 组装订单 createOrderModel.getChildOrderList().add(createOrderChildModel); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 877de769..9f93b665 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -1168,38 +1168,6 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return childOrder; } - @Override - public HighChildOrder oilCard(HighOrder order, CreateOrderChildModel createOrderChildModel) { - // 查询油卡 - HighOilCard card = oilCardService.getOilCardByCardNo(createOrderChildModel.getGoodsId().toString()); - if (card == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡"); - } - - HighChildOrder childOrder = new HighChildOrder(); - childOrder.setOrderNo(order.getOrderNo()); - childOrder.setMemId(order.getMemId()); - childOrder.setMemName(order.getMemName()); - childOrder.setMemPhone(order.getMemPhone()); - childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); - childOrder.setGoodsType(OrderChildGoodsType.TYPE15.getNumber()); - childOrder.setGoodsId(card.getId()); - childOrder.setGoodsName("油卡充值"); - childOrder.setGoodsSpecName(card.getCardNo()); - childOrder.setGoodsPrice(createOrderChildModel.getGoodsPrice()); - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - childOrder.setSaleCount(createOrderChildModel.getSaleCount()); - childOrder.setGiveawayType(false); - childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); - childOrder.setTotalPrice(childOrder.getGoodsPrice()); - childOrder.setTotalActualPrice(childOrder.getGoodsPrice()); - childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); - childOrder.setPraiseStatus(0); - childOrder.setCreateTime(new Date()); - - return childOrder; - } - @Override public HighChildOrder group(HighOrder order, CreateOrderChildModel createOrderChildModel) throws Exception { @@ -1254,78 +1222,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return childOrder; } - @Override - public HighChildOrder oilCard(HighOrder order, CreateOrderChildModel createOrderChildModel) { - // 查询油卡 - HighOilCard card = oilCardService.getOilCardByCardNo(createOrderChildModel.getGoodsId().toString()); - if (card == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡"); - } - - // 充值金额 - BigDecimal rechargeAmount = createOrderChildModel.getGoodsPrice(); - // 赠送金额 - BigDecimal givePrice = new BigDecimal("0"); - - SecConfig rechargeRatio = secConfigService.findByCodeType("OIL_CARD_RECHARGE_RATIO"); - if (rechargeRatio != null && StringUtils.isNotBlank(rechargeRatio.getCodeValue())) { - BigDecimal ratio = new BigDecimal(rechargeRatio.getCodeValue()).divide(new BigDecimal("100")); - givePrice = rechargeAmount.multiply(ratio).setScale(2, RoundingMode.DOWN); - } - - HighChildOrder childOrder = new HighChildOrder(); - childOrder.setOrderNo(order.getOrderNo()); - childOrder.setMemId(order.getMemId()); - childOrder.setMemName(order.getMemName()); - childOrder.setMemPhone(order.getMemPhone()); - childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); - childOrder.setGoodsType(OrderChildGoodsType.TYPE15.getNumber()); - childOrder.setGoodsId(card.getId()); - childOrder.setGoodsName("油卡充值"); - childOrder.setGoodsSpecName(card.getCardNo()); - childOrder.setGoodsPrice(rechargeAmount.add(givePrice)); - childOrder.setGoodsActualPrice(createOrderChildModel.getGoodsPrice()); - childOrder.setSaleCount(createOrderChildModel.getSaleCount()); - childOrder.setGiveawayType(false); - childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); - childOrder.setTotalPrice(childOrder.getGoodsPrice()); - childOrder.setTotalActualPrice(createOrderChildModel.getGoodsPrice()); - childOrder.setTotalDeductionPrice(createOrderChildModel.getGoodsPrice().subtract(childOrder.getTotalActualPrice())); - childOrder.setPraiseStatus(0); - childOrder.setCreateTime(new Date()); - childOrder.setExt1(givePrice.toString()); - return childOrder; - } - - @Override - public HighChildOrder petroCoupon(HighOrder order, CreateOrderChildModel createOrderChildModel) throws Exception { - ApiCoupon apiCoupon = apiCouponService.findCoupon(createOrderChildModel.getCouponCode()); - - // 生成交易子订单 - HighChildOrder childOrder = new HighChildOrder(); - childOrder.setOrderNo(order.getOrderNo()); - childOrder.setMemId(order.getMemId()); - childOrder.setMemName(order.getMemName()); - childOrder.setMemPhone(order.getMemPhone()); - childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); - childOrder.setGoodsType(OrderChildGoodsType.TYPE12.getNumber()); - childOrder.setGoodsId(apiCoupon.getId()); - childOrder.setGoodsName(apiCoupon.getName()); - childOrder.setGoodsSpecName(apiCoupon.getCode()); - childOrder.setGoodsPrice(new BigDecimal(apiCoupon.getPrice())); - childOrder.setGoodsActualPrice(createOrderChildModel.getPrice()); - childOrder.setSaleCount(createOrderChildModel.getSaleCount()); - childOrder.setGiveawayType(false); - childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); - childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount()))); - childOrder.setTotalActualPrice(childOrder.getGoodsActualPrice().multiply(new BigDecimal(childOrder.getSaleCount()))); - childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); - childOrder.setPraiseStatus(0); - childOrder.setCreateTime(new Date()); - - return childOrder; - } @Override public HighChildOrder oilCard(HighOrder order, CreateOrderChildModel createOrderChildModel) { @@ -1372,7 +1269,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { } @Override - public HighChildOrder petroCoupon(HighOrder order, CreateOrderChildModel createOrderChildModel) throws Exception { + public HighChildOrder petroCoupon(HighOrder order, CreateOrderChildModel createOrderChildModel) { ApiCoupon apiCoupon = apiCouponService.findCoupon(createOrderChildModel.getCouponCode()); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index 859560d7..9c024acb 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -686,7 +686,6 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { private void petroCoupon(HighOrder order , HighChildOrder childOrder) throws Exception { - // 派发停车券 ApiCoupon apiCoupon = apiCouponService.findCoupon(childOrder.getGoodsSpecName()); diff --git a/hai-service/src/main/java/com/hai/service/BsTemporaryServices.java b/hai-service/src/main/java/com/hai/service/BsTemporaryServices.java new file mode 100644 index 00000000..49e4528c --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/BsTemporaryServices.java @@ -0,0 +1,54 @@ +package com.hai.service; + +import com.hai.entity.BsMsg; +import com.hai.entity.BsPushScheduleTask; +import com.hai.entity.BsTemporary; + +import java.util.List; +import java.util.Map; + +public interface BsTemporaryServices { + + /** + * @Author Sum1Dream + * @Name insert + * @Description // 新增 + * @Date 16:22 2023/12/22 + * @Param bsTemporary + * @return void + */ + void insert(BsTemporary bsTemporary); + + /** + * @Author Sum1Dream + * @Name update + * @Description // 更新 + * @Date 16:23 2023/12/22 + * @Param bsTemporary + * @return void + */ + void update(BsTemporary bsTemporary); + + /** + * @Author Sum1Dream + * @Name findById + * @Description // 查询 + * @Date 16:23 2023/12/22 + * @Param id + * @return com.hai.entity.BsMsg + */ + BsTemporary findById(Long id); + + BsTemporary findByCode(String openId , Integer type); + + /** + * @Author Sum1Dream + * @Name getList + * @Description // 查询列表 + * @Date 16:23 2023/12/22 + * @Param map + * @return java.util.List + */ + List getList(Map map); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java b/hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java index c0030d42..95a2c4a4 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java @@ -2,6 +2,8 @@ package com.hai.service; import com.hai.entity.HighDiscountPackageActual; import com.hai.entity.HighDiscountPackageDiscountActual; +import io.swagger.models.auth.In; +import javassist.runtime.Inner; import java.util.List; import java.util.Map; @@ -93,4 +95,6 @@ public interface HighDiscountPackageActualService { */ Long userPurchaseByUserId(Integer userId , Integer discountPackage); + Integer receivePackageLimit(Integer userId , Integer discountPackage , Integer dat); + } 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 84566d73..03ca790b 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java @@ -1,14 +1,12 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; -import com.hai.entity.HighDiscount; import com.hai.entity.HighDiscountPackage; import com.hai.entity.HighDiscountPackageActual; import com.hai.entity.HighDiscountPackageRecord; +import com.hai.entity.HighUser; import com.hai.model.UserInfoModel; -import io.swagger.models.auth.In; -import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -116,7 +114,7 @@ public interface HighDiscountPackageService { * @Param [packageId, phone, sourceType, sourceId] * @Return java.lang.String */ - String giveAway(Long packageId, String phone , Integer sourceType , String sourceId) throws Exception; + void giveAway(Long packageId, String phone , Integer sourceType , String sourceId) throws Exception; /** * @Author Sum1Dream @@ -126,6 +124,8 @@ public interface HighDiscountPackageService { * @Param object * @return void */ - void receivePackage(Integer discountPackageActualId , String code); + void receivePackage(JSONObject object, HighUser user ); + + void decodeCode(String code , HighUser highUser); } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsTemporaryServicesImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsTemporaryServicesImpl.java new file mode 100644 index 00000000..faf3662c --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/BsTemporaryServicesImpl.java @@ -0,0 +1,55 @@ +package com.hai.service.impl; + +import com.hai.dao.BsTemporaryMapper; +import com.hai.entity.BsMsg; +import com.hai.entity.BsTemporary; +import com.hai.entity.BsTemporaryExample; +import com.hai.service.BsTemporaryServices; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Service("bsTemporaryServices") +public class BsTemporaryServicesImpl implements BsTemporaryServices { + + @Resource + private BsTemporaryMapper bsTemporaryMapper; + + @Override + public void insert(BsTemporary bsTemporary) { + bsTemporaryMapper.insert(bsTemporary); + } + + @Override + public void update(BsTemporary bsTemporary) { + bsTemporaryMapper.updateByPrimaryKey(bsTemporary); + } + + @Override + public BsTemporary findById(Long id) { + return bsTemporaryMapper.selectByPrimaryKey(id); + } + + @Override + public BsTemporary findByCode(String openId , Integer type) { + BsTemporaryExample example = new BsTemporaryExample(); + example.createCriteria().andSourceCodeEqualTo(openId).andTypeEqualTo(type).andStatusEqualTo(1); + + List list = bsTemporaryMapper.selectByExample(example); + + if (list.size() > 0 ) { + return list.get(0); + } + + return null; + } + + @Override + public List getList(Map map) { + BsTemporaryExample example = new BsTemporaryExample(); + example.createCriteria().andStatusEqualTo(1); + return bsTemporaryMapper.selectByExample(example); + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java index 7bf6190e..fa904ccf 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java @@ -160,6 +160,7 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ return list; } + @Override public List getDiscountUseCount(Map map) { HighDiscountAgentRelExample example = new HighDiscountAgentRelExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java index 695b5b10..4903bf75 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java @@ -103,4 +103,10 @@ public class HighDiscountPackageActualServiceImpl implements HighDiscountPackage example.createCriteria().andDiscountPackageIdEqualTo(discountPackage).andUserIdEqualTo(userId).andStatusIn(statusList); return discountPackageActualMapper.countByExample(example); } + + @Override + public Integer receivePackageLimit(Integer userId, Integer discountPackageId , Integer day) { + List list = discountPackageActualMapper.receivePackageLimit( userId, discountPackageId , day); + return list.size(); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java index 98ee82d6..1f498174 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java @@ -155,7 +155,7 @@ public class HighDiscountPackageAgentServiceImpl implements HighDiscountPackageA mapCode.put("type" , "DISCOUNT_PACKAGE"); int percent; - for (int i = 1; i <= object.getInteger("num"); i++) { + for (int i = 0; i <= object.getInteger("num"); i++) { // 生成百分比 percent = i*100/object.getInteger("num"); @@ -269,6 +269,9 @@ public class HighDiscountPackageAgentServiceImpl implements HighDiscountPackageA if (MapUtils.getLong(map, "discountPackageId") != null) { criteria.andDiscountPackageIdEqualTo(MapUtils.getLong(map, "discountPackageId")); } + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } return discountPackageAgentCodeMapper.selectByExample(example); } 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 b7ef226b..46aeea96 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 @@ -1,12 +1,13 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.github.pagehelper.PageHelper; -import com.google.common.base.Stopwatch; +import com.hai.common.Base64Util; import com.hai.common.exception.BaseException; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; @@ -18,21 +19,15 @@ import com.hai.model.HighUserModel; import com.hai.model.UserInfoModel; import com.hai.service.*; import com.hai.service.HighDiscountPackageService; -import io.lettuce.core.RedisURI; import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StopWatch; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; import java.util.*; -import java.util.stream.Collectors; /** * @serviceName HighDiscountPackageServiceImpl.java @@ -103,6 +98,9 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic @Autowired private RedisUtil redisUtil; + @Resource + private SecConfigService secConfigService; + @Override public List getDiscountPackageList(Map map) { @@ -465,7 +463,7 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic } @Override - public String giveAway(Long packageId, String phone, Integer sourceType, String sourceId) { + public void giveAway(Long packageId, String phone, Integer sourceType, String sourceId) { // 查询优惠券包 HighDiscountPackage discountPackage = findDiscountPackageById(packageId.intValue()); @@ -554,14 +552,15 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic redisUtil.del(serialNum); }).start(); - return serialNum; } - @Override - @Transactional(propagation= Propagation.REQUIRED) - public void receivePackage(Integer discountPackageActualId , String code) { - HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + + @Override + @Transactional(propagation= Propagation.NESTED) + public void receivePackage(JSONObject objectData , HighUser user) { + Integer discountPackageActualId = objectData.getInteger("discountPackageActualId"); + String code = objectData.getString("code"); String key = "receivePackage_" + discountPackageActualId; try { @@ -574,10 +573,11 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic HighDiscountPackageAgentCode discountPackageAgentCode = discountPackageAgentService.findDiscountPackageAgentCode(code); + if (discountPackageAgentCode == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前系统繁忙,请联系客服人员!"); } - if (discountPackageAgentCode.getStatus() != 1) { + if (discountPackageAgentCode.getStatus() == 2 || discountPackageAgentCode.getStatus() == 3 || discountPackageAgentCode.getStatus() == 4 ) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "券包已领取!"); } @@ -611,10 +611,11 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic object.put("discountPackageName" , discountPackage.getTitle()); object.put("discountPackageId" , discountPackage.getId()); - object.put("userId" , userInfoModel.getHighUser().getId()); - object.put("userName" , userInfoModel.getHighUser().getName()); - object.put("userPhone" , userInfoModel.getHighUser().getPhone()); + object.put("userId" , user.getId()); + object.put("userName" , user.getName()); + object.put("userPhone" , user.getPhone()); object.put("companyId" , discountPackage.getCompanyId()); + object.put("agentId" , discountPackageAgentCode.getAgentId()); object.put("discountPackageActualId" , discountPackageActualId); object.put("usingAttribution" , 3); object.put("type" , 3); @@ -638,7 +639,7 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic } else { // 加锁失败,重试 Thread.sleep(100); - receivePackage(discountPackageActualId , code); + receivePackage(objectData , user); } } catch (BaseException baseException) { redisTemplate.delete(key); @@ -655,6 +656,31 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic + } + + @Override + public void decodeCode(String code , HighUser user) { + try { + // 用户 + String jsonData; + jsonData = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); + + JSONObject jsonObject = JSON.parseObject(jsonData); + String type = jsonObject.getString("type"); + + if (!type.equals("DISCOUNT_PACKAGE")){ + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前业务不支持!"); + } + + JSONObject object = new JSONObject(); + object.put("code" , code); + object.put("discountPackageActualId" , jsonObject.getInteger("id")); + + highDiscountPackageService.receivePackage(object , user); + } catch (Exception e) { + System.out.println(e); + } + } private void getDiscountPackageDeliver(JSONObject object) { @@ -705,7 +731,9 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic userRel.setDiscountUsingRange(discount.getUsingRange()); userRel.setDiscountType(discount.getDiscountType()); userRel.setDiscountCondition(discount.getDiscountCondition()); + userRel.setExt1(object.getString("agentId")); userRel.setExt2("优惠券包"); + userRel.setExt3(object.getString("userPhone")); userRel.setDiscountPrice(discount.getDiscountPrice()); userRel.setAgentId(actualList.getAgentId()); userRel.setUserId(object.getLong("userId")); @@ -754,4 +782,12 @@ public class HighDiscountPackageServiceImpl implements HighDiscountPackageServic discountPackageRecord.setCreatedTime(new Date()); highDiscountPackageRecordMapper.insert(discountPackageRecord); } + + // 查询当前是否已经超出使用 + private Boolean receivePackageLimit(Integer userId , Integer num , Integer discountPackageId , Integer day) { + return num <= discountPackageActualService.receivePackageLimit(userId, discountPackageId , day); + } + + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index 9a5018fa..ee8e1e14 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -276,6 +276,12 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic if (MapUtils.getLong(map, "userId") != null) { criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); } + if (MapUtils.getLong(map, "agentId") != null) { + criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId")); + } + if (MapUtils.getLong(map, "discountName") != null) { + criteria.andDiscountNameLike(MapUtils.getString(map, "discountName")); + } if (MapUtils.getInteger(map, "discountPlatform") != null) { criteria.andDiscountPlatformEqualTo(MapUtils.getInteger(map, "discountPlatform")); @@ -285,6 +291,10 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } + if (MapUtils.getString(map, "ext1") != null) { + criteria.andExt1EqualTo(MapUtils.getString(map, "ext1")); + } + if (MapUtils.getInteger(map, "discountUseScope") != null) { criteria.andDiscountUseScopeEqualTo(MapUtils.getInteger(map, "discountUseScope")); } 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 db67ff22..0362b015 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 @@ -49,6 +49,9 @@ public class HighUserServiceImpl implements HighUserService { @Resource private HighGoldRecService highGoldRecService; + @Resource + private HighDiscountPackageService highDiscountPackageService; + @Resource private HighUserCouponService highUserCouponService; @@ -83,7 +86,8 @@ public class HighUserServiceImpl implements HighUserService { private HighUserLoginLogMapper userLoginLogMapper; @Resource - private HighStoreUserService highStoreUserService; + private BsTemporaryServices bsTemporaryServices; + @Override @Transactional(propagation = Propagation.REQUIRES_NEW, timeout = 30, rollbackFor = Exception.class) @@ -136,12 +140,25 @@ public class HighUserServiceImpl implements HighUserService { distributionUserRelService.insertDistributionUserRel(user.getId(), popularizeUserId, region.getRegionId().toString()); } } - + user.setOpenIdH5(MapUtils.getString(other, "openIdH5")); user.setOpenId(MapUtils.getString(other, "openId")); loginLog.setUserId(user.getId()); userLoginLogMapper.insert(loginLog); + if (user.getOpenIdH5() != null) { + + BsTemporary bsTemporary = bsTemporaryServices.findByCode(user.getOpenIdH5() , 7); + + if (bsTemporary != null) { + bsTemporary.setStatus(0); + bsTemporary.setUpdateTime(new Date()); + bsTemporaryServices.update(bsTemporary); + highDiscountPackageService.decodeCode(bsTemporary.getCode() , user); + } + } + + // 缓存登录信息 HighUserModel highUserModel = new HighUserModel(); highUserModel.setHighUser(getDetailDataByUser(user.getId())); diff --git a/hai-user/src/main/java/com/web/controller/LoginController.java b/hai-user/src/main/java/com/web/controller/LoginController.java index 65e63471..d9397154 100644 --- a/hai-user/src/main/java/com/web/controller/LoginController.java +++ b/hai-user/src/main/java/com/web/controller/LoginController.java @@ -1 +1 @@ -package com.web.controller; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; 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.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.config.WxMaConfiguration; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.type.PlatformType; import com.hai.service.HighUserService; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import javafx.application.Platform; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private UserCenter userCenter; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); Map other = new HashMap<>(); other.put("storeId", body.getLong("storeId")); if (LoginPlatform.H5.getCode().equals(body.getString("platform"))) { other.put("openIdH5", body.getString("openId")); } if (LoginPlatform.WXAPPLETS.getCode().equals(body.getString("platform"))) { other.put("openId", body.getString("openId")); } return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), other, request, response)); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/openId", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "openId登录") public ResponseData openId(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("openId")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.WECHAT_MA_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openId", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())){ return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } else if (body.getString("type").equals(LoginType.WECHAT_MP_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openIdH5", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())) { return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } WxMaJscode2SessionResult session; if (body.getInteger("type") != null) { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService(body.getInteger("type")).jsCode2SessionInfo(body.getString("code")); } else { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); } //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } System.out.println("============================" + body); String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo; if (body.getInteger("type") != null) { phoneNoInfo = WxMaConfiguration .getMaService(body.getInteger("type")) .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } else { phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); other.put("storeId", body.getLong("storeId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/out", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") public ResponseData out(HttpServletRequest request, HttpServletResponse response) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } userCenter.remove(request, response); return ResponseMsgUtil.success("退出登录成功"); } catch (Exception e) { log.error("CoresController --> outLogin() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.web.controller; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; 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.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.config.WxMaConfiguration; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.order.type.PlatformType; import com.hai.service.HighUserService; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import javafx.application.Platform; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private UserCenter userCenter; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); System.out.println(body); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); Map other = new HashMap<>(); other.put("storeId", body.getLong("storeId")); if (LoginPlatform.H5.getCode().equals(body.getString("platform"))) { other.put("openIdH5", body.getString("openId")); } if (LoginPlatform.WXAPPLETS.getCode().equals(body.getString("platform"))) { other.put("openId", body.getString("openId")); } return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), other, request, response)); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/openId", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "openId登录") public ResponseData openId(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("openId")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.WECHAT_MA_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openId", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())){ return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } else if (body.getString("type").equals(LoginType.WECHAT_MP_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openIdH5", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())) { return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } WxMaJscode2SessionResult session; if (body.getInteger("type") != null) { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService(body.getInteger("type")).jsCode2SessionInfo(body.getString("code")); } else { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); } //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } System.out.println("============================" + body); String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo; if (body.getInteger("type") != null) { phoneNoInfo = WxMaConfiguration .getMaService(body.getInteger("type")) .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } else { phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); other.put("storeId", body.getLong("storeId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/out", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") public ResponseData out(HttpServletRequest request, HttpServletResponse response) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } userCenter.remove(request, response); return ResponseMsgUtil.success("退出登录成功"); } catch (Exception e) { log.error("CoresController --> outLogin() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/v1/src/main/java/com/v1/controller/orderController.java b/v1/src/main/java/com/v1/controller/orderController.java index ac3bbb7a..862424af 100644 --- a/v1/src/main/java/com/v1/controller/orderController.java +++ b/v1/src/main/java/com/v1/controller/orderController.java @@ -167,33 +167,7 @@ public class orderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写下单手机号,就餐方式,下单信息,门店编码"); } } -// if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE13.getNumber())) { -// if ( StringUtils.isBlank(dataObject.getString("couponCode")) -// || StringUtils.isBlank(dataObject.getString("userMobile")) -// || dataObject.getInteger("receiverCount") == null -// ) { -// log.error("OrderController -> create() error!",""); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写卡券编码,手机号,购买数量"); -// } -// } -// if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE14.getNumber())) { -// if ( StringUtils.isBlank(dataObject.getString("userMobile")) -// || StringUtils.isBlank(dataObject.getString("userCouponCode")) -// || StringUtils.isBlank(dataObject.getString("parkOrderId")) -// || StringUtils.isBlank(dataObject.getString("parkName")) -// || dataObject.getInteger("orderType") == null -// || dataObject.getBigDecimal("prePrice") == null -// || dataObject.getBigDecimal("currentamt") == null -// || dataObject.getInteger("parkId") == null -// || dataObject.getInteger("parkTime") == null -// || dataObject.getString("inTime") == null -// || dataObject.getString("outTime") == null -// || dataObject.getString("carNo") == null -// ) { -// log.error("OrderController -> create() error!",""); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未填写相关参数"); -// } -// } + if (object.getInteger("productType").equals(OrderProductType.PRODUCT_TYPE18.getNumber())) { if ( StringUtils.isBlank(dataObject.getString("userMobile")) || StringUtils.isBlank(dataObject.getString("couponCode"))