Merge remote-tracking branch 'origin/2.0-dev' into 2.0-dev

new-dev
袁野 11 months ago
parent 39b5450654
commit e90f4107cd
  1. 1
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java
  2. 33
      hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java
  3. 2
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  4. 149
      hai-cweb/src/main/java/com/cweb/controller/HighDiscountPackageController.java
  5. 105
      hai-order/src/main/java/com/web/controller/business/ApiMerOrderController.java
  6. 21
      hai-service/src/main/java/com/hai/dao/HighDiscountPackageActualMapperExt.java
  7. 8
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderCreateHandleServiceImpl.java
  8. 1
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiOrderServiceImpl.java
  9. 105
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  10. 1
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  11. 54
      hai-service/src/main/java/com/hai/service/BsTemporaryServices.java
  12. 4
      hai-service/src/main/java/com/hai/service/HighDiscountPackageActualService.java
  13. 10
      hai-service/src/main/java/com/hai/service/HighDiscountPackageService.java
  14. 55
      hai-service/src/main/java/com/hai/service/impl/BsTemporaryServicesImpl.java
  15. 1
      hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentRelServiceImpl.java
  16. 6
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageActualServiceImpl.java
  17. 5
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java
  18. 74
      hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageServiceImpl.java
  19. 10
      hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java
  20. 19
      hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java
  21. 2
      hai-user/src/main/java/com/web/controller/LoginController.java
  22. 28
      v1/src/main/java/com/v1/controller/orderController.java

@ -195,6 +195,7 @@ public class HighDiscountAgentRelController {
}
}
@RequestMapping(value="/getDiscountCodeList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询优惠券码 列表")

@ -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<String, Object> 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);
}
}
}

@ -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")

@ -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<String, Object> param = new HashMap<>();
param.put("openIdH5", openId);
List<HighUser> userList = userService.getUserList(param);
try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, openId);
if (Boolean.TRUE.equals(lock)) {
Map<String , Object> map = new HashMap<>();
map.put("agentId" , agentId);
map.put("discountPackageId" , packageId);
map.put("status" , 1);
List<HighDiscountPackageAgentCode> 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<BsTemporary> 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("领取成功!");

@ -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<String,Object> 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<String, Object> 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);
}
}
}

@ -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<HighDiscountPackageActual> receivePackageLimit(@Param("userId") Integer userId, @Param("discountPackageId") Integer discountPackageId, @Param("day") Integer day);
}

@ -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<String, Object> 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"));

@ -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);

@ -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());

@ -686,7 +686,6 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
private void petroCoupon(HighOrder order , HighChildOrder childOrder) throws Exception {
// 派发停车券
ApiCoupon apiCoupon = apiCouponService.findCoupon(childOrder.getGoodsSpecName());

@ -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<com.hai.entity.BsMsg>
*/
List<BsTemporary> getList(Map<String , Object> map);
}

@ -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);
}

@ -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);
}

@ -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<BsTemporary> list = bsTemporaryMapper.selectByExample(example);
if (list.size() > 0 ) {
return list.get(0);
}
return null;
}
@Override
public List<BsTemporary> getList(Map<String, Object> map) {
BsTemporaryExample example = new BsTemporaryExample();
example.createCriteria().andStatusEqualTo(1);
return bsTemporaryMapper.selectByExample(example);
}
}

@ -160,6 +160,7 @@ public class HighDiscountAgentRelServiceImpl implements HighDiscountAgentRelServ
return list;
}
@Override
public List<HighDiscountAgentRel> getDiscountUseCount(Map<String, Object> map) {
HighDiscountAgentRelExample example = new HighDiscountAgentRelExample();

@ -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 <HighDiscountPackageActual> list = discountPackageActualMapper.receivePackageLimit( userId, discountPackageId , day);
return list.size();
}
}

@ -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);
}

@ -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<HighDiscountPackage> getDiscountPackageList(Map<String, Object> 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);
}
}

@ -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"));
}

@ -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)
@ -142,6 +146,19 @@ public class HighUserServiceImpl implements HighUserService {
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()));

File diff suppressed because one or more lines are too long

@ -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"))

Loading…
Cancel
Save