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 79359147..7f6c9c51 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java @@ -10,6 +10,7 @@ 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; @@ -47,6 +48,8 @@ public class HighDiscountController { @Resource private HighDiscountService highDiscountService; + @Resource + private HighDiscountUserRelService discountUserRelService; @Resource private HighDiscountUserRelService discountUserRelService; 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-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java index 0c3eb470..92908b3e 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -1,9 +1,9 @@ package com.hai.schedule; -import com.hai.entity.HighDiscountAgentCode; -import com.hai.entity.HighDiscountUserRel; -import com.hai.entity.HighOrder; +import com.hai.entity.*; +import com.hai.service.BsTemporaryServices; import com.hai.service.HighDiscountAgentCodeService; +import com.hai.service.HighDiscountPackageAgentService; import com.hai.service.HighDiscountUserRelService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,6 +11,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; import java.util.List; /** @@ -29,6 +31,12 @@ public class HighDiscountSchedule { @Resource private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource + private BsTemporaryServices bsTemporaryServices; + + @Resource + private HighDiscountPackageAgentService discountPackageAgentService; + /** * @Author 胡锐 * @Description 处理过期的优惠券 @@ -55,4 +63,23 @@ public class HighDiscountSchedule { } } + + @Scheduled(cron = "0 5 0 * * ?") // 每日凌晨00:00:5执行一次 + public void deleteOilNo() { + 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); + + } + + } + } diff --git a/hai-service/src/main/java/com/hai/dao/BsTemporaryMapper.java b/hai-service/src/main/java/com/hai/dao/BsTemporaryMapper.java new file mode 100644 index 00000000..ea264cff --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/BsTemporaryMapper.java @@ -0,0 +1,125 @@ +package com.hai.dao; + +import com.hai.entity.BsTemporary; +import com.hai.entity.BsTemporaryExample; +import java.util.List; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Options; +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.annotations.SelectProvider; +import org.apache.ibatis.annotations.Update; +import org.apache.ibatis.annotations.UpdateProvider; +import org.apache.ibatis.type.JdbcType; +import org.springframework.stereotype.Repository; + +/** + * + * 代码由工具生成,请勿修改!!! + * 如果需要扩展请在其父类进行扩展 + * + **/ +@Repository +public interface BsTemporaryMapper extends BsTemporaryMapperExt { + @SelectProvider(type=BsTemporarySqlProvider.class, method="countByExample") + long countByExample(BsTemporaryExample example); + + @DeleteProvider(type=BsTemporarySqlProvider.class, method="deleteByExample") + int deleteByExample(BsTemporaryExample example); + + @Delete({ + "delete from bs_temporary", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into bs_temporary (code, `type`, ", + "source_code, create_time, ", + "update_time, `status`, ", + "op_id, op_name, ext_1, ", + "ext_2, ext_3)", + "values (#{code,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, ", + "#{sourceCode,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", + "#{opId,jdbcType=BIGINT}, #{opName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(BsTemporary record); + + @InsertProvider(type=BsTemporarySqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(BsTemporary record); + + @SelectProvider(type=BsTemporarySqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="source_code", property="sourceCode", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="op_id", property="opId", jdbcType=JdbcType.BIGINT), + @Result(column="op_name", property="opName", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + List selectByExample(BsTemporaryExample example); + + @Select({ + "select", + "id, code, `type`, source_code, create_time, update_time, `status`, op_id, op_name, ", + "ext_1, ext_2, ext_3", + "from bs_temporary", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="code", property="code", jdbcType=JdbcType.VARCHAR), + @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="source_code", property="sourceCode", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @Result(column="op_id", property="opId", jdbcType=JdbcType.BIGINT), + @Result(column="op_name", property="opName", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR), + @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) + }) + BsTemporary selectByPrimaryKey(Long id); + + @UpdateProvider(type=BsTemporarySqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") BsTemporary record, @Param("example") BsTemporaryExample example); + + @UpdateProvider(type=BsTemporarySqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") BsTemporary record, @Param("example") BsTemporaryExample example); + + @UpdateProvider(type=BsTemporarySqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(BsTemporary record); + + @Update({ + "update bs_temporary", + "set code = #{code,jdbcType=VARCHAR},", + "`type` = #{type,jdbcType=INTEGER},", + "source_code = #{sourceCode,jdbcType=VARCHAR},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "update_time = #{updateTime,jdbcType=TIMESTAMP},", + "`status` = #{status,jdbcType=INTEGER},", + "op_id = #{opId,jdbcType=BIGINT},", + "op_name = #{opName,jdbcType=VARCHAR},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(BsTemporary record); +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/BsTemporaryMapperExt.java b/hai-service/src/main/java/com/hai/dao/BsTemporaryMapperExt.java new file mode 100644 index 00000000..d8da17a7 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/BsTemporaryMapperExt.java @@ -0,0 +1,7 @@ +package com.hai.dao; + +/** + * mapper扩展类 + */ +public interface BsTemporaryMapperExt { +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/BsTemporarySqlProvider.java b/hai-service/src/main/java/com/hai/dao/BsTemporarySqlProvider.java new file mode 100644 index 00000000..79c5b192 --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/BsTemporarySqlProvider.java @@ -0,0 +1,332 @@ +package com.hai.dao; + +import com.hai.entity.BsTemporary; +import com.hai.entity.BsTemporaryExample.Criteria; +import com.hai.entity.BsTemporaryExample.Criterion; +import com.hai.entity.BsTemporaryExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class BsTemporarySqlProvider { + + public String countByExample(BsTemporaryExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("bs_temporary"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(BsTemporaryExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("bs_temporary"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(BsTemporary record) { + SQL sql = new SQL(); + sql.INSERT_INTO("bs_temporary"); + + if (record.getCode() != null) { + sql.VALUES("code", "#{code,jdbcType=VARCHAR}"); + } + + if (record.getType() != null) { + sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); + } + + if (record.getSourceCode() != null) { + sql.VALUES("source_code", "#{sourceCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + if (record.getOpId() != null) { + sql.VALUES("op_id", "#{opId,jdbcType=BIGINT}"); + } + + if (record.getOpName() != null) { + sql.VALUES("op_name", "#{opName,jdbcType=VARCHAR}"); + } + + if (record.getExt1() != null) { + sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}"); + } + + return sql.toString(); + } + + public String selectByExample(BsTemporaryExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("code"); + sql.SELECT("`type`"); + sql.SELECT("source_code"); + sql.SELECT("create_time"); + sql.SELECT("update_time"); + sql.SELECT("`status`"); + sql.SELECT("op_id"); + sql.SELECT("op_name"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("bs_temporary"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + BsTemporary record = (BsTemporary) parameter.get("record"); + BsTemporaryExample example = (BsTemporaryExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("bs_temporary"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getCode() != null) { + sql.SET("code = #{record.code,jdbcType=VARCHAR}"); + } + + if (record.getType() != null) { + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + } + + if (record.getSourceCode() != null) { + sql.SET("source_code = #{record.sourceCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + if (record.getOpId() != null) { + sql.SET("op_id = #{record.opId,jdbcType=BIGINT}"); + } + + if (record.getOpName() != null) { + sql.SET("op_name = #{record.opName,jdbcType=VARCHAR}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + } + + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByExample(Map parameter) { + SQL sql = new SQL(); + sql.UPDATE("bs_temporary"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("code = #{record.code,jdbcType=VARCHAR}"); + sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + sql.SET("source_code = #{record.sourceCode,jdbcType=VARCHAR}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("op_id = #{record.opId,jdbcType=BIGINT}"); + sql.SET("op_name = #{record.opName,jdbcType=VARCHAR}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + BsTemporaryExample example = (BsTemporaryExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(BsTemporary record) { + SQL sql = new SQL(); + sql.UPDATE("bs_temporary"); + + if (record.getCode() != null) { + sql.SET("code = #{code,jdbcType=VARCHAR}"); + } + + if (record.getType() != null) { + sql.SET("`type` = #{type,jdbcType=INTEGER}"); + } + + if (record.getSourceCode() != null) { + sql.SET("source_code = #{sourceCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getUpdateTime() != null) { + sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + if (record.getOpId() != null) { + sql.SET("op_id = #{opId,jdbcType=BIGINT}"); + } + + if (record.getOpName() != null) { + sql.SET("op_name = #{opName,jdbcType=VARCHAR}"); + } + + if (record.getExt1() != null) { + sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}"); + } + + if (record.getExt2() != null) { + sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}"); + } + + if (record.getExt3() != null) { + sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}"); + } + + sql.WHERE("id = #{id,jdbcType=BIGINT}"); + + return sql.toString(); + } + + protected void applyWhere(SQL sql, BsTemporaryExample example, boolean includeExamplePhrase) { + if (example == null) { + return; + } + + String parmPhrase1; + String parmPhrase1_th; + String parmPhrase2; + String parmPhrase2_th; + String parmPhrase3; + String parmPhrase3_th; + if (includeExamplePhrase) { + parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } else { + parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}"; + parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}"; + parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}"; + parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}"; + parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}"; + parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}"; + } + + StringBuilder sb = new StringBuilder(); + List oredCriteria = example.getOredCriteria(); + boolean firstCriteria = true; + for (int i = 0; i < oredCriteria.size(); i++) { + Criteria criteria = oredCriteria.get(i); + if (criteria.isValid()) { + if (firstCriteria) { + firstCriteria = false; + } else { + sb.append(" or "); + } + + sb.append('('); + List criterions = criteria.getAllCriteria(); + boolean firstCriterion = true; + for (int j = 0; j < criterions.size(); j++) { + Criterion criterion = criterions.get(j); + if (firstCriterion) { + firstCriterion = false; + } else { + sb.append(" and "); + } + + if (criterion.isNoValue()) { + sb.append(criterion.getCondition()); + } else if (criterion.isSingleValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j)); + } else { + sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler())); + } + } else if (criterion.isBetweenValue()) { + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j)); + } else { + sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler())); + } + } else if (criterion.isListValue()) { + sb.append(criterion.getCondition()); + sb.append(" ("); + List listItems = (List) criterion.getValue(); + boolean comma = false; + for (int k = 0; k < listItems.size(); k++) { + if (comma) { + sb.append(", "); + } else { + comma = true; + } + if (criterion.getTypeHandler() == null) { + sb.append(String.format(parmPhrase3, i, j, k)); + } else { + sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler())); + } + } + sb.append(')'); + } + } + sb.append(')'); + } + } + + if (sb.length() > 0) { + sql.WHERE(sb.toString()); + } + } +} \ No newline at end of file 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/entity/BsTemporary.java b/hai-service/src/main/java/com/hai/entity/BsTemporary.java new file mode 100644 index 00000000..be1111f9 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/BsTemporary.java @@ -0,0 +1,241 @@ +package com.hai.entity; + +import java.io.Serializable; +import java.util.Date; + +/** + * bs_temporary + * @author + */ +/** + * + * 代码由工具生成 + * + **/ +public class BsTemporary implements Serializable { + /** + * 主键 + */ + private Long id; + + /** + * 编码 + */ + private String code; + + /** + * 类型:1:星巴克 2:肯德基 3:会员充值 4:积分充值 5:购买卡券 6:加油服务 7:优惠券包 8:汇联通充值 9:话费充值 10:电影票 11:贵州中石化 12:实物商品 13:比邻星停车场 + */ + private Integer type; + + /** + * 来源 + */ + private String sourceCode; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 状态 1:正常 0 删除 + */ + private Integer status; + + /** + * 操作人 + */ + private Long opId; + + /** + * 操作人名称 + */ + private String opName; + + /** + * ext_1 + */ + private String ext1; + + /** + * ext_2 + */ + private String ext2; + + /** + * ext_3 + */ + private String ext3; + + private static final long serialVersionUID = 1L; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getSourceCode() { + return sourceCode; + } + + public void setSourceCode(String sourceCode) { + this.sourceCode = sourceCode; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Long getOpId() { + return opId; + } + + public void setOpId(Long opId) { + this.opId = opId; + } + + public String getOpName() { + return opName; + } + + public void setOpName(String opName) { + this.opName = opName; + } + + public String getExt1() { + return ext1; + } + + public void setExt1(String ext1) { + this.ext1 = ext1; + } + + public String getExt2() { + return ext2; + } + + public void setExt2(String ext2) { + this.ext2 = ext2; + } + + public String getExt3() { + return ext3; + } + + public void setExt3(String ext3) { + this.ext3 = ext3; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + BsTemporary other = (BsTemporary) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode())) + && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) + && (this.getSourceCode() == null ? other.getSourceCode() == null : this.getSourceCode().equals(other.getSourceCode())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getOpId() == null ? other.getOpId() == null : this.getOpId().equals(other.getOpId())) + && (this.getOpName() == null ? other.getOpName() == null : this.getOpName().equals(other.getOpName())) + && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) + && (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2())) + && (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode()); + result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getSourceCode() == null) ? 0 : getSourceCode().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getOpId() == null) ? 0 : getOpId().hashCode()); + result = prime * result + ((getOpName() == null) ? 0 : getOpName().hashCode()); + result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); + result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode()); + result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", code=").append(code); + sb.append(", type=").append(type); + sb.append(", sourceCode=").append(sourceCode); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", status=").append(status); + sb.append(", opId=").append(opId); + sb.append(", opName=").append(opName); + sb.append(", ext1=").append(ext1); + sb.append(", ext2=").append(ext2); + sb.append(", ext3=").append(ext3); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/entity/BsTemporaryExample.java b/hai-service/src/main/java/com/hai/entity/BsTemporaryExample.java new file mode 100644 index 00000000..f24ef8a2 --- /dev/null +++ b/hai-service/src/main/java/com/hai/entity/BsTemporaryExample.java @@ -0,0 +1,1003 @@ +package com.hai.entity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +public class BsTemporaryExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + private Integer limit; + + private Long offset; + + public BsTemporaryExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getLimit() { + return limit; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + + public Long getOffset() { + return offset; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(Long value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(Long value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(Long value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(Long value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(Long value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(Long value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(Long value1, Long value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(Long value1, Long value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(Integer value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(Integer value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(Integer value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(Integer value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(Integer value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(Integer value1, Integer value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(Integer value1, Integer value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andSourceCodeIsNull() { + addCriterion("source_code is null"); + return (Criteria) this; + } + + public Criteria andSourceCodeIsNotNull() { + addCriterion("source_code is not null"); + return (Criteria) this; + } + + public Criteria andSourceCodeEqualTo(String value) { + addCriterion("source_code =", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeNotEqualTo(String value) { + addCriterion("source_code <>", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeGreaterThan(String value) { + addCriterion("source_code >", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeGreaterThanOrEqualTo(String value) { + addCriterion("source_code >=", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeLessThan(String value) { + addCriterion("source_code <", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeLessThanOrEqualTo(String value) { + addCriterion("source_code <=", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeLike(String value) { + addCriterion("source_code like", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeNotLike(String value) { + addCriterion("source_code not like", value, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeIn(List values) { + addCriterion("source_code in", values, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeNotIn(List values) { + addCriterion("source_code not in", values, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeBetween(String value1, String value2) { + addCriterion("source_code between", value1, value2, "sourceCode"); + return (Criteria) this; + } + + public Criteria andSourceCodeNotBetween(String value1, String value2) { + addCriterion("source_code not between", value1, value2, "sourceCode"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Date value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Date value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Date value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Date value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Date value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Date value1, Date value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Date value1, Date value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Date value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Date value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Date value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Date value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Date value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Date value1, Date value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Date value1, Date value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andStatusIsNull() { + addCriterion("`status` is null"); + return (Criteria) this; + } + + public Criteria andStatusIsNotNull() { + addCriterion("`status` is not null"); + return (Criteria) this; + } + + public Criteria andStatusEqualTo(Integer value) { + addCriterion("`status` =", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotEqualTo(Integer value) { + addCriterion("`status` <>", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThan(Integer value) { + addCriterion("`status` >", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusGreaterThanOrEqualTo(Integer value) { + addCriterion("`status` >=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThan(Integer value) { + addCriterion("`status` <", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusLessThanOrEqualTo(Integer value) { + addCriterion("`status` <=", value, "status"); + return (Criteria) this; + } + + public Criteria andStatusIn(List values) { + addCriterion("`status` in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotIn(List values) { + addCriterion("`status` not in", values, "status"); + return (Criteria) this; + } + + public Criteria andStatusBetween(Integer value1, Integer value2) { + addCriterion("`status` between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andStatusNotBetween(Integer value1, Integer value2) { + addCriterion("`status` not between", value1, value2, "status"); + return (Criteria) this; + } + + public Criteria andOpIdIsNull() { + addCriterion("op_id is null"); + return (Criteria) this; + } + + public Criteria andOpIdIsNotNull() { + addCriterion("op_id is not null"); + return (Criteria) this; + } + + public Criteria andOpIdEqualTo(Long value) { + addCriterion("op_id =", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdNotEqualTo(Long value) { + addCriterion("op_id <>", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdGreaterThan(Long value) { + addCriterion("op_id >", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdGreaterThanOrEqualTo(Long value) { + addCriterion("op_id >=", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdLessThan(Long value) { + addCriterion("op_id <", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdLessThanOrEqualTo(Long value) { + addCriterion("op_id <=", value, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdIn(List values) { + addCriterion("op_id in", values, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdNotIn(List values) { + addCriterion("op_id not in", values, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdBetween(Long value1, Long value2) { + addCriterion("op_id between", value1, value2, "opId"); + return (Criteria) this; + } + + public Criteria andOpIdNotBetween(Long value1, Long value2) { + addCriterion("op_id not between", value1, value2, "opId"); + return (Criteria) this; + } + + public Criteria andOpNameIsNull() { + addCriterion("op_name is null"); + return (Criteria) this; + } + + public Criteria andOpNameIsNotNull() { + addCriterion("op_name is not null"); + return (Criteria) this; + } + + public Criteria andOpNameEqualTo(String value) { + addCriterion("op_name =", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameNotEqualTo(String value) { + addCriterion("op_name <>", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameGreaterThan(String value) { + addCriterion("op_name >", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameGreaterThanOrEqualTo(String value) { + addCriterion("op_name >=", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameLessThan(String value) { + addCriterion("op_name <", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameLessThanOrEqualTo(String value) { + addCriterion("op_name <=", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameLike(String value) { + addCriterion("op_name like", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameNotLike(String value) { + addCriterion("op_name not like", value, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameIn(List values) { + addCriterion("op_name in", values, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameNotIn(List values) { + addCriterion("op_name not in", values, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameBetween(String value1, String value2) { + addCriterion("op_name between", value1, value2, "opName"); + return (Criteria) this; + } + + public Criteria andOpNameNotBetween(String value1, String value2) { + addCriterion("op_name not between", value1, value2, "opName"); + return (Criteria) this; + } + + public Criteria andExt1IsNull() { + addCriterion("ext_1 is null"); + return (Criteria) this; + } + + public Criteria andExt1IsNotNull() { + addCriterion("ext_1 is not null"); + return (Criteria) this; + } + + public Criteria andExt1EqualTo(String value) { + addCriterion("ext_1 =", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotEqualTo(String value) { + addCriterion("ext_1 <>", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThan(String value) { + addCriterion("ext_1 >", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1GreaterThanOrEqualTo(String value) { + addCriterion("ext_1 >=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThan(String value) { + addCriterion("ext_1 <", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1LessThanOrEqualTo(String value) { + addCriterion("ext_1 <=", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Like(String value) { + addCriterion("ext_1 like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotLike(String value) { + addCriterion("ext_1 not like", value, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1In(List values) { + addCriterion("ext_1 in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotIn(List values) { + addCriterion("ext_1 not in", values, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1Between(String value1, String value2) { + addCriterion("ext_1 between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt1NotBetween(String value1, String value2) { + addCriterion("ext_1 not between", value1, value2, "ext1"); + return (Criteria) this; + } + + public Criteria andExt2IsNull() { + addCriterion("ext_2 is null"); + return (Criteria) this; + } + + public Criteria andExt2IsNotNull() { + addCriterion("ext_2 is not null"); + return (Criteria) this; + } + + public Criteria andExt2EqualTo(String value) { + addCriterion("ext_2 =", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotEqualTo(String value) { + addCriterion("ext_2 <>", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThan(String value) { + addCriterion("ext_2 >", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2GreaterThanOrEqualTo(String value) { + addCriterion("ext_2 >=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThan(String value) { + addCriterion("ext_2 <", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2LessThanOrEqualTo(String value) { + addCriterion("ext_2 <=", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Like(String value) { + addCriterion("ext_2 like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotLike(String value) { + addCriterion("ext_2 not like", value, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2In(List values) { + addCriterion("ext_2 in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotIn(List values) { + addCriterion("ext_2 not in", values, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2Between(String value1, String value2) { + addCriterion("ext_2 between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt2NotBetween(String value1, String value2) { + addCriterion("ext_2 not between", value1, value2, "ext2"); + return (Criteria) this; + } + + public Criteria andExt3IsNull() { + addCriterion("ext_3 is null"); + return (Criteria) this; + } + + public Criteria andExt3IsNotNull() { + addCriterion("ext_3 is not null"); + return (Criteria) this; + } + + public Criteria andExt3EqualTo(String value) { + addCriterion("ext_3 =", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotEqualTo(String value) { + addCriterion("ext_3 <>", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThan(String value) { + addCriterion("ext_3 >", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3GreaterThanOrEqualTo(String value) { + addCriterion("ext_3 >=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThan(String value) { + addCriterion("ext_3 <", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3LessThanOrEqualTo(String value) { + addCriterion("ext_3 <=", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Like(String value) { + addCriterion("ext_3 like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotLike(String value) { + addCriterion("ext_3 not like", value, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3In(List values) { + addCriterion("ext_3 in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotIn(List values) { + addCriterion("ext_3 not in", values, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3Between(String value1, String value2) { + addCriterion("ext_3 between", value1, value2, "ext3"); + return (Criteria) this; + } + + public Criteria andExt3NotBetween(String value1, String value2) { + addCriterion("ext_3 not between", value1, value2, "ext3"); + return (Criteria) this; + } + } + + /** + */ + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ 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 4d0bb0b0..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 @@ -496,7 +496,6 @@ public class ApiOrderCreateHandleServiceImpl implements ApiOrderCreateHandleServ throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前卡券已停用!"); } - // 查询折扣比例 Map mapProduct = new HashMap<>(); mapProduct.put("mchId" , 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 a823023d..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 @@ -58,12 +58,16 @@ public class ApiOrderServiceImpl implements ApiOrderService { @Override + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) public ApiOrder createOrder(JSONObject object) throws Exception { + ApiOrder apiOrder = new ApiOrder(); + // 获取下单内容 JSONObject dataObject = JSONObject.parseObject(object.getString("content")); + CreateOrderModel createOrderModel = new CreateOrderModel(); createOrderModel.setChildOrderList(new ArrayList<>()); @@ -278,8 +282,6 @@ public class ApiOrderServiceImpl implements ApiOrderService { createOrderChildModel.setIsTyAgent(false); createOrderChildModel.setGoodsPrice(apiOrder.getOrderPrice()); createOrderChildModel.setPrice(apiOrder.getCostPrice()); - createOrderModel.setMemName("接口用户"); - createOrderModel.setMemPhone(dataObject.getString("userMobile")); // 组装订单 createOrderModel.getChildOrderList().add(createOrderChildModel); @@ -305,7 +307,7 @@ public class ApiOrderServiceImpl implements ApiOrderService { @Override - @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW , timeout = 30) + @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) public ApiOrder payOrder(JSONObject object) throws Exception{ ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); diff --git a/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java b/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java index 1b2f224a..7ef07873 100644 --- a/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java +++ b/hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java @@ -62,7 +62,6 @@ public class ExportOrderMobileModel { private String orderStatus; - @ColumnWidth(15) @ExcelProperty("创建时间") private Date createTime; 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 fc6c6bff..60ba6544 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 @@ -687,7 +687,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/order/type/OrderChildGoodsType.java b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java index cff944d3..3dd5be66 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java @@ -22,8 +22,8 @@ public enum OrderChildGoodsType { TYPE11(11, "实物商品购买"), TYPE12(12, "比邻星停车券"), TYPE13(13, "比邻星停车"), - TYPE14(14, "个人油卡充值"), - TYPE15(15, "升级会员"), + TYPE14(14, "升级会员"), + TYPE15(15, "个人油卡充值"), TYPE17(17, "团购套餐"), TYPE18(18, "中石油卡券"), ; 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 9ec056f8..899e897d 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 @@ -168,11 +168,12 @@ public class HighDiscountPackageAgentServiceImpl implements HighDiscountPackageA HighDiscountPackageAgentCode discountPackageAgentCode ; mapCode.put("type" , "DISCOUNT_PACKAGE"); int percent; + int num = object.getInteger("num"); - for (int i = 1; i <= object.getInteger("num"); i++) { + for (int i = 0; i < object.getInteger("num"); i++) { // 生成百分比 - percent = i*100/object.getInteger("num"); + percent = i*100/(num -1); redisUtil.set(object.getString("serialNumber") , percent , 3600); HighDiscountPackageActual discountPackageActual = discountPackageActualList.get(i); @@ -283,6 +284,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 6bbcb2f4..4822a6c2 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.getString(map, "discountName") != null) { + criteria.andDiscountNameLike("%" + MapUtils.getString(map, "discountName") + "%"); + } if (MapUtils.getInteger(map, "discountPlatform") != null) { criteria.andDiscountPlatformEqualTo(MapUtils.getInteger(map, "discountPlatform")); @@ -288,6 +294,10 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic criteria.andExt1EqualTo(MapUtils.getString(map, "ext1")); } + 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 e06ad284..91e77fa6 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"))