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 ac0964d2..689f3bc3 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -99,11 +99,12 @@ public class HighDiscountAgentRelController { log.error("HighDiscountAgentRelController -> insertDiscountAgent() error!", discount.getDiscountName() + "重复分配给" + agent.getAgentName()); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, discount.getDiscountName() + "重复分配给" + agent.getAgentName()); } + highDiscountAgentRel.setCreateTime(new Date()); highDiscountAgentRel.setStatus(1); highDiscountAgentRelService.insertDiscountAgentRel(highDiscountAgentRel); - // 生成二维码 +/* // 生成二维码 String qrCodeImg = DateUtil.date2String(new Date(),agent.getId() + discount.getId() + "yyyyMMddHHmmss") + IDGenerator.nextId(2) +".png"; String qrCodeUrl = SysConst.getSysConfig().getAgentQrCode() + "/" + qrCodeImg; @@ -111,7 +112,7 @@ public class HighDiscountAgentRelController { String url = SysConst.getSysConfig().getAgentQrCodeWxUrl() + highDiscountAgentRel.getId(); QRCodeGenerator.generateQRCodeImage(url, 350, 350, qrCodeUrl); highDiscountAgentRel.setQrCode(qrCodeImg); - highDiscountAgentRelService.updateDiscountAgentRel(highDiscountAgentRel); + highDiscountAgentRelService.updateDiscountAgentRel(highDiscountAgentRel);*/ return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java index 4df3a7f4..bba8ad97 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantController.java @@ -124,7 +124,6 @@ public class HighMerchantController { || StringUtils.isBlank(highMerchant.getMerchantName()) || StringUtils.isBlank(highMerchant.getTelephone()) || StringUtils.isBlank(highMerchant.getAddress()) - || StringUtils.isBlank(highMerchant.getTelephone()) ) { log.error("HighMerchantController -> updateMerchant() error!","参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); @@ -156,13 +155,21 @@ public class HighMerchantController { throw ErrorHelp.genException(SysCode.System, ErrorCode.PHONE_NUM_EXISTED, ""); } - highMerchant.setUpdateTime(new Date()); - highMerchant.setOperatorId(userInfoModel.getSecUser().getId()); - highMerchant.setOperatorName(userInfoModel.getSecUser().getUserName()); - highMerchant.setCompanyId(userInfoModel.getBsCompany().getId()); - highMerchantService.updateMerchant(highMerchant); - - return ResponseMsgUtil.success(highMerchant); + merchant.setMerchantName(highMerchant.getMerchantName()); + merchant.setTelephone(highMerchant.getTelephone()); + merchant.setAddress(highMerchant.getAddress()); + merchant.setBankName(highMerchant.getBankName()); + merchant.setBankHolder(highMerchant.getBankHolder()); + merchant.setBankAccount(highMerchant.getBankAccount()); + merchant.setMerchantLogo(highMerchant.getMerchantLogo()); + merchant.setMerchantDesc(highMerchant.getMerchantDesc()); + merchant.setUpdateTime(new Date()); + merchant.setOperatorId(userInfoModel.getSecUser().getId()); + merchant.setOperatorName(userInfoModel.getSecUser().getUserName()); + merchant.setCompanyId(userInfoModel.getBsCompany().getId()); + highMerchantService.updateMerchant(merchant); + + return ResponseMsgUtil.success(merchant); } catch (Exception e) { log.error("HighMerchantController -> updateMerchant() error!",e); return ResponseMsgUtil.exception(e); diff --git a/hai-bweb/src/main/resources/prod/config.properties b/hai-bweb/src/main/resources/prod/config.properties index 6e43f1df..69132629 100644 --- a/hai-bweb/src/main/resources/prod/config.properties +++ b/hai-bweb/src/main/resources/prod/config.properties @@ -1,4 +1,4 @@ fileUrl=/home/project/hsg/filesystem cmsPath=/home/project/hsg/filesystem/cmsPath agentQrCode=/home/project/hsg/filesystem/agentQrCode -agentQrCodeWxUrl=https://hsgcs.dctpay.com/wx/test?id= +agentQrCodeWxUrl=https://hsg.dctpay.com/wx/?action=gogogo&id= diff --git a/hai-bweb/src/test/common/ExcelModel.java b/hai-bweb/src/test/common/ExcelModel.java index ed6f11db..363a7913 100644 --- a/hai-bweb/src/test/common/ExcelModel.java +++ b/hai-bweb/src/test/common/ExcelModel.java @@ -9,25 +9,14 @@ import com.alibaba.excel.annotation.ExcelProperty; */ public class ExcelModel { - @ExcelProperty("卡券编码") - private String key; + @ExcelProperty("二维码地址") + private String codeUrl; - @ExcelProperty("商品编码") - private String name; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getName() { - return name; + public String getCodeUrl() { + return codeUrl; } - public void setName(String name) { - this.name = name; + public void setCodeUrl(String codeUrl) { + this.codeUrl = codeUrl; } } diff --git a/hai-bweb/src/test/common/RegionTest.java b/hai-bweb/src/test/common/RegionTest.java index b1aacb56..0d5da036 100644 --- a/hai-bweb/src/test/common/RegionTest.java +++ b/hai-bweb/src/test/common/RegionTest.java @@ -1,10 +1,15 @@ package common; import com.BWebApplication; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; +import com.hai.common.Base64Util; +import com.hai.common.security.AESEncodeUtil; +import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.SecRegion; import com.hai.service.CommonService; +import com.hai.service.HighDiscountAgentCodeService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; @@ -33,6 +38,9 @@ public class RegionTest { @Resource private CommonService commonService; + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Test public void addLogs(){ try { @@ -67,4 +75,32 @@ public class RegionTest { e.printStackTrace(); } } + + @Test + public void simpleWrite() throws Exception { + // 写法1 + String fileName = "D:\\simpleWrite.xlsx"; + + + Map paramMap = new HashMap<>(); + paramMap.put("discountAgentId", ""); + List codeList = highDiscountAgentCodeService.getDiscountCode(paramMap); + + List list = new ArrayList<>(); + ExcelModel excelModel; + + Map map = new HashMap<>(); + map.put("type", "DISCOUNT"); + + for (HighDiscountAgentCode code : codeList) { + excelModel = new ExcelModel(); + map.put("id", code.getId()); + String param = "https://hsg.dctpay.com/wx/?action=gogogo&id=" + Base64Util.encode(AESEncodeUtil.aesEncrypt(JSON.toJSONString(map))); + excelModel.setCodeUrl(param); + list.add(excelModel); + } + // 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭 + // 如果这里想使用03 则 传入excelType参数即可 + EasyExcel.write(fileName, ExcelModel.class).sheet("模板").doWrite(list); + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java index 48e712cb..a6af5a78 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java @@ -11,6 +11,7 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.BsCompany; import com.hai.entity.HighCoupon; import com.hai.entity.HighUserCoupon; +import com.hai.entity.SecRegion; import com.hai.model.HighUserCouponModel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; @@ -61,6 +62,9 @@ public class HighCouponController { @Resource private HighMerchantStoreService highMerchantStoreService; + @Resource + private CommonService commonService; + @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷列表") @@ -73,20 +77,22 @@ public class HighCouponController { @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { - BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(regionId); - if (bsCompany != null) { - Map map = new HashMap<>(); - map.put("companyId", bsCompany.getId()); - map.put("merchantId", merchantId); - map.put("couponName", couponName); - map.put("couponType", couponType); - map.put("displayArea", displayArea); - map.put("notCouponSource", 2); - map.put("status", 2); - PageHelper.startPage(pageNum, pageSize); - return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); + SecRegion region = commonService.getRegionsById(Long.parseLong(regionId)); + if (region != null && region.getParentId() != null) { + BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getParentId().toString()); + if (bsCompany != null) { + Map map = new HashMap<>(); + map.put("companyId", bsCompany.getId()); + map.put("merchantId", merchantId); + map.put("couponName", couponName); + map.put("couponType", couponType); + map.put("displayArea", displayArea); + map.put("notCouponSource", 2); + map.put("status", 2); + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); + } } - return ResponseMsgUtil.success(new PageInfo<>()); } catch (Exception e) { @@ -158,7 +164,7 @@ public class HighCouponController { } Map map = new HashMap<>(); - map.put("highUserCoupon", "coupon"); + map.put("highUserCoupon", coupon); map.put("couponInfo", highCouponService.getCouponById(coupon.getCouponId())); map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(coupon.getCouponCodeId())); @@ -186,7 +192,7 @@ public class HighCouponController { HighUserCoupon userCoupon = highUserCouponService.againReceiveCoupon(userInfoModel.getHighUser().getId(), couponId); Map map = new HashMap<>(); - map.put("highUserCoupon", "coupon"); + map.put("highUserCoupon", userCoupon); map.put("couponInfo", highCouponService.getCouponById(userCoupon.getCouponId())); map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(userCoupon.getCouponCodeId())); return ResponseMsgUtil.success(map); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java index 51bfafdd..3882861b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighDiscountController.java @@ -1,12 +1,17 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.hai.common.Base64Util; 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.utils.ResponseMsgUtil; +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighDiscountAgentRel; import com.hai.model.ResponseData; +import com.hai.service.HighDiscountAgentCodeService; import com.hai.service.HighDiscountAgentRelService; import com.hai.service.HighDiscountCouponRelService; import com.hai.service.HighDiscountService; @@ -18,6 +23,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; /** * @Auther: 胡锐 @@ -25,7 +32,7 @@ import javax.annotation.Resource; * @Date: 2021/4/4 14:46 */ @Controller -@RequestMapping(value = "/discount") + @RequestMapping(value = "/discount") @Api(value = "优惠券接口") public class HighDiscountController { @@ -37,6 +44,9 @@ public class HighDiscountController { @Resource private HighDiscountCouponRelService highDiscountCouponRelService; + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource private HighDiscountService highDiscountService; @@ -45,14 +55,27 @@ public class HighDiscountController { @ApiOperation(value = "根据二维码Code查询") public ResponseData getDiscountByQrCode(@RequestParam(name = "code", required = true) String code) { try { - String relId; + String jsonData; try { - relId = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); + jsonData = AESEncodeUtil.aesDecrypt(Base64Util.decode(code)); } catch (Exception e) { log.error("HighDiscountController -> getDiscountByQrCode() error!","code解码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "code解码错误"); } - return ResponseMsgUtil.success(highDiscountAgentRelService.getRelById(Long.parseLong(relId))); + + JSONObject jsonObject = JSON.parseObject(jsonData); + String type = jsonObject.getString("type"); + Long id = jsonObject.getLong("id"); + + HighDiscountAgentCode discountAgentCode = highDiscountAgentCodeService.getCodeById(id); + if (discountAgentCode != null) { + HighDiscountAgentRel rel = highDiscountAgentRelService.getRelById(discountAgentCode.getDiscountAgentId()); + if (rel != null) { + rel.setHighDiscountAgentCode(discountAgentCode); + return ResponseMsgUtil.success(rel); + } + } + return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighDiscountController -> getDiscountByQrCode() error!",e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java index 10d2f508..2f142663 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserDiscountController.java @@ -10,10 +10,12 @@ import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighDiscount; +import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.HighDiscountCouponRel; import com.hai.entity.HighDiscountUserRel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; +import com.hai.service.HighDiscountAgentCodeService; import com.hai.service.HighDiscountCouponRelService; import com.hai.service.HighDiscountUserRelService; import io.swagger.annotations.Api; @@ -64,13 +66,13 @@ public class HighUserDiscountController { HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); JSONObject jsonObject = JSONObject.parseObject(reqBody); - Long discountAgentId = jsonObject.getLong("discountAgentId"); - if (discountAgentId == null) { + Long codeId = jsonObject.getLong("codeId"); + if (codeId == null) { log.error("HighDiscountController -> receiveDiscount() error!", "参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 领取 - highDiscountUserRelService.receiveDiscount(userInfoModel.getHighUser().getId(), discountAgentId); + highDiscountUserRelService.receiveDiscount(userInfoModel.getHighUser().getId(), codeId); return ResponseMsgUtil.success("领取成功"); } catch (Exception e) { diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index a8985ab6..0243f904 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -109,7 +109,7 @@ public class OrderController { // 商品类型 1:卡卷 2:金币充值 for (HighChildOrder childOrder : order.getHighChildOrderList()) { - if (childOrder.getGoodsType() == 1) { + if (childOrder.getGiveawayType() == false && childOrder.getGoodsType() == 1) { HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); // 支付类型:1.微信支付 2.金币支付 if (coupon.getPayType() != 1) { 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 9abb88cf..0c3eb470 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -1,7 +1,9 @@ package com.hai.schedule; +import com.hai.entity.HighDiscountAgentCode; import com.hai.entity.HighDiscountUserRel; import com.hai.entity.HighOrder; +import com.hai.service.HighDiscountAgentCodeService; import com.hai.service.HighDiscountUserRelService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,23 +26,33 @@ public class HighDiscountSchedule { @Resource private HighDiscountUserRelService highDiscountUserRelService; + @Resource + private HighDiscountAgentCodeService highDiscountAgentCodeService; + /** * @Author 胡锐 * @Description 处理过期的优惠券 * @Date 2021/4/4 22:44 **/ - @Scheduled(cron = "5 0 0 * * ?") //每日凌晨12点5秒执行一次 + //@Scheduled(cron = "5 0 0 * * ?") //每日凌晨12点5秒执行一次 + @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次 public void expiredDiscount() { List expiredDiscount = highDiscountUserRelService.getExpiredDiscount(); for (HighDiscountUserRel rel : expiredDiscount) { try { rel.setStatus(0); highDiscountUserRelService.updateDiscountUserRel(rel); + + // 二维码 + HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); + if (code != null) { + code.setStatus(4); // 状态 0:删除 1:待领取 2:待使用 3:已使用 4:已过期 + highDiscountAgentCodeService.updateCode(code); + } } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } - } } diff --git a/hai-service/src/main/java/com/hai/common/QRCodeGenerator.java b/hai-service/src/main/java/com/hai/common/QRCodeGenerator.java index 79d08953..7ac839f9 100644 --- a/hai-service/src/main/java/com/hai/common/QRCodeGenerator.java +++ b/hai-service/src/main/java/com/hai/common/QRCodeGenerator.java @@ -6,6 +6,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; +import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; @@ -22,15 +23,18 @@ public class QRCodeGenerator { BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height); - Path path = FileSystems.getDefault().getPath(filePath); - - MatrixToImageWriter.writeToPath(bitMatrix, "PNG", path); + File file = new File(filePath); + if(!file.exists()){ + file.mkdirs(); + } + //Path path = FileSystems.getDefault().getPath(filePath); + MatrixToImageWriter.writeToFile(bitMatrix, "PNG", file); } public static void main(String[] args) { try { - generateQRCodeImage("This is my first QR Code", 350, 350, "D:\\qr.png"); + generateQRCodeImage("This is my first QR Code", 350, 350, "D:\\/ss/qr1.png"); } catch (WriterException e) { System.out.println("Could not generate QR Code, WriterException :: " + e.getMessage()); } catch (IOException e) { diff --git a/hai-service/src/main/java/com/hai/common/security/UserCenter.java b/hai-service/src/main/java/com/hai/common/security/UserCenter.java index 43c9d1e9..0916cc3c 100644 --- a/hai-service/src/main/java/com/hai/common/security/UserCenter.java +++ b/hai-service/src/main/java/com/hai/common/security/UserCenter.java @@ -19,7 +19,7 @@ public class UserCenter { private static Logger log = LoggerFactory.getLogger(UserCenter.class); private static final String COOKIE_FIELD = "_ida"; - private static final int EXPIRE = 43200;//过期时间为12小时 + private static final int EXPIRE = 86400 * 7;//过期时间为24小时 * 7天 /** * 判断用户是否登录,并且不能单个用户同时登录 diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapper.java b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapper.java new file mode 100644 index 00000000..782a367a --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapper.java @@ -0,0 +1,108 @@ +package com.hai.dao; + +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighDiscountAgentCodeExample; +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 HighDiscountAgentCodeMapper extends HighDiscountAgentCodeMapperExt { + @SelectProvider(type=HighDiscountAgentCodeSqlProvider.class, method="countByExample") + long countByExample(HighDiscountAgentCodeExample example); + + @DeleteProvider(type=HighDiscountAgentCodeSqlProvider.class, method="deleteByExample") + int deleteByExample(HighDiscountAgentCodeExample example); + + @Delete({ + "delete from high_discount_agent_code", + "where id = #{id,jdbcType=BIGINT}" + }) + int deleteByPrimaryKey(Long id); + + @Insert({ + "insert into high_discount_agent_code (discount_agent_id, qr_code, ", + "create_time, `status`, ", + "ext_1, ext_2, ext_3)", + "values (#{discountAgentId,jdbcType=BIGINT}, #{qrCode,jdbcType=VARCHAR}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + }) + @Options(useGeneratedKeys=true,keyProperty="id") + int insert(HighDiscountAgentCode record); + + @InsertProvider(type=HighDiscountAgentCodeSqlProvider.class, method="insertSelective") + @Options(useGeneratedKeys=true,keyProperty="id") + int insertSelective(HighDiscountAgentCode record); + + @SelectProvider(type=HighDiscountAgentCodeSqlProvider.class, method="selectByExample") + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT), + @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @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(HighDiscountAgentCodeExample example); + + @Select({ + "select", + "id, discount_agent_id, qr_code, create_time, `status`, ext_1, ext_2, ext_3", + "from high_discount_agent_code", + "where id = #{id,jdbcType=BIGINT}" + }) + @Results({ + @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), + @Result(column="discount_agent_id", property="discountAgentId", jdbcType=JdbcType.BIGINT), + @Result(column="qr_code", property="qrCode", jdbcType=JdbcType.VARCHAR), + @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), + @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), + @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) + }) + HighDiscountAgentCode selectByPrimaryKey(Long id); + + @UpdateProvider(type=HighDiscountAgentCodeSqlProvider.class, method="updateByExampleSelective") + int updateByExampleSelective(@Param("record") HighDiscountAgentCode record, @Param("example") HighDiscountAgentCodeExample example); + + @UpdateProvider(type=HighDiscountAgentCodeSqlProvider.class, method="updateByExample") + int updateByExample(@Param("record") HighDiscountAgentCode record, @Param("example") HighDiscountAgentCodeExample example); + + @UpdateProvider(type=HighDiscountAgentCodeSqlProvider.class, method="updateByPrimaryKeySelective") + int updateByPrimaryKeySelective(HighDiscountAgentCode record); + + @Update({ + "update high_discount_agent_code", + "set discount_agent_id = #{discountAgentId,jdbcType=BIGINT},", + "qr_code = #{qrCode,jdbcType=VARCHAR},", + "create_time = #{createTime,jdbcType=TIMESTAMP},", + "`status` = #{status,jdbcType=INTEGER},", + "ext_1 = #{ext1,jdbcType=VARCHAR},", + "ext_2 = #{ext2,jdbcType=VARCHAR},", + "ext_3 = #{ext3,jdbcType=VARCHAR}", + "where id = #{id,jdbcType=BIGINT}" + }) + int updateByPrimaryKey(HighDiscountAgentCode record); +} \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java new file mode 100644 index 00000000..903f527e --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeMapperExt.java @@ -0,0 +1,33 @@ +package com.hai.dao; + +import com.hai.entity.HighDiscountAgentCode; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * mapper扩展类 + */ +public interface HighDiscountAgentCodeMapperExt { + + @Insert({ + "" + }) + void insertListCode(@Param(value = "list") List discountAgentCodeList); + +} diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeSqlProvider.java new file mode 100644 index 00000000..98af898b --- /dev/null +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountAgentCodeSqlProvider.java @@ -0,0 +1,276 @@ +package com.hai.dao; + +import com.hai.entity.HighDiscountAgentCode; +import com.hai.entity.HighDiscountAgentCodeExample.Criteria; +import com.hai.entity.HighDiscountAgentCodeExample.Criterion; +import com.hai.entity.HighDiscountAgentCodeExample; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.jdbc.SQL; + +public class HighDiscountAgentCodeSqlProvider { + + public String countByExample(HighDiscountAgentCodeExample example) { + SQL sql = new SQL(); + sql.SELECT("count(*)").FROM("high_discount_agent_code"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String deleteByExample(HighDiscountAgentCodeExample example) { + SQL sql = new SQL(); + sql.DELETE_FROM("high_discount_agent_code"); + applyWhere(sql, example, false); + return sql.toString(); + } + + public String insertSelective(HighDiscountAgentCode record) { + SQL sql = new SQL(); + sql.INSERT_INTO("high_discount_agent_code"); + + if (record.getDiscountAgentId() != null) { + sql.VALUES("discount_agent_id", "#{discountAgentId,jdbcType=BIGINT}"); + } + + if (record.getQrCode() != null) { + sql.VALUES("qr_code", "#{qrCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); + } + + 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(HighDiscountAgentCodeExample example) { + SQL sql = new SQL(); + if (example != null && example.isDistinct()) { + sql.SELECT_DISTINCT("id"); + } else { + sql.SELECT("id"); + } + sql.SELECT("discount_agent_id"); + sql.SELECT("qr_code"); + sql.SELECT("create_time"); + sql.SELECT("`status`"); + sql.SELECT("ext_1"); + sql.SELECT("ext_2"); + sql.SELECT("ext_3"); + sql.FROM("high_discount_agent_code"); + applyWhere(sql, example, false); + + if (example != null && example.getOrderByClause() != null) { + sql.ORDER_BY(example.getOrderByClause()); + } + + return sql.toString(); + } + + public String updateByExampleSelective(Map parameter) { + HighDiscountAgentCode record = (HighDiscountAgentCode) parameter.get("record"); + HighDiscountAgentCodeExample example = (HighDiscountAgentCodeExample) parameter.get("example"); + + SQL sql = new SQL(); + sql.UPDATE("high_discount_agent_code"); + + if (record.getId() != null) { + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + } + + if (record.getDiscountAgentId() != null) { + sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}"); + } + + if (record.getQrCode() != null) { + sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + } + + 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("high_discount_agent_code"); + + sql.SET("id = #{record.id,jdbcType=BIGINT}"); + sql.SET("discount_agent_id = #{record.discountAgentId,jdbcType=BIGINT}"); + sql.SET("qr_code = #{record.qrCode,jdbcType=VARCHAR}"); + sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); + sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); + sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); + sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}"); + sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}"); + + HighDiscountAgentCodeExample example = (HighDiscountAgentCodeExample) parameter.get("example"); + applyWhere(sql, example, true); + return sql.toString(); + } + + public String updateByPrimaryKeySelective(HighDiscountAgentCode record) { + SQL sql = new SQL(); + sql.UPDATE("high_discount_agent_code"); + + if (record.getDiscountAgentId() != null) { + sql.SET("discount_agent_id = #{discountAgentId,jdbcType=BIGINT}"); + } + + if (record.getQrCode() != null) { + sql.SET("qr_code = #{qrCode,jdbcType=VARCHAR}"); + } + + if (record.getCreateTime() != null) { + sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}"); + } + + if (record.getStatus() != null) { + sql.SET("`status` = #{status,jdbcType=INTEGER}"); + } + + 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, HighDiscountAgentCodeExample 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/HighDiscountUserRelMapper.java b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java index 0e0f3fab..8d482d39 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java @@ -40,11 +40,13 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Insert({ "insert into high_discount_user_rel (discount_id, agent_id, ", - "user_id, `status`, use_time, ", + "discount_agent_code_id, user_id, ", + "`status`, use_time, ", "create_time, use_end_time, ", "ext_1, ext_2, ext_3)", "values (#{discountId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", - "#{userId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{useTime,jdbcType=TIMESTAMP}, ", + "#{discountAgentCodeId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ", + "#{status,jdbcType=INTEGER}, #{useTime,jdbcType=TIMESTAMP}, ", "#{createTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @@ -60,6 +62,7 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), + @Result(column="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="use_time", property="useTime", jdbcType=JdbcType.TIMESTAMP), @@ -73,8 +76,8 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Select({ "select", - "id, discount_id, agent_id, user_id, `status`, use_time, create_time, use_end_time, ", - "ext_1, ext_2, ext_3", + "id, discount_id, agent_id, discount_agent_code_id, user_id, `status`, use_time, ", + "create_time, use_end_time, ext_1, ext_2, ext_3", "from high_discount_user_rel", "where id = #{id,jdbcType=BIGINT}" }) @@ -82,6 +85,7 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), + @Result(column="discount_agent_code_id", property="discountAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="use_time", property="useTime", jdbcType=JdbcType.TIMESTAMP), @@ -106,6 +110,7 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt "update high_discount_user_rel", "set discount_id = #{discountId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", + "discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT},", "user_id = #{userId,jdbcType=BIGINT},", "`status` = #{status,jdbcType=INTEGER},", "use_time = #{useTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java index 54556153..37a99bc8 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java @@ -36,6 +36,10 @@ public class HighDiscountUserRelSqlProvider { sql.VALUES("agent_id", "#{agentId,jdbcType=BIGINT}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.VALUES("discount_agent_code_id", "#{discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getUserId() != null) { sql.VALUES("user_id", "#{userId,jdbcType=BIGINT}"); } @@ -80,6 +84,7 @@ public class HighDiscountUserRelSqlProvider { } sql.SELECT("discount_id"); sql.SELECT("agent_id"); + sql.SELECT("discount_agent_code_id"); sql.SELECT("user_id"); sql.SELECT("`status`"); sql.SELECT("use_time"); @@ -117,6 +122,10 @@ public class HighDiscountUserRelSqlProvider { sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getUserId() != null) { sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); } @@ -160,6 +169,7 @@ public class HighDiscountUserRelSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("discount_id = #{record.discountId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); + sql.SET("discount_agent_code_id = #{record.discountAgentCodeId,jdbcType=BIGINT}"); sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("use_time = #{record.useTime,jdbcType=TIMESTAMP}"); @@ -186,6 +196,10 @@ public class HighDiscountUserRelSqlProvider { sql.SET("agent_id = #{agentId,jdbcType=BIGINT}"); } + if (record.getDiscountAgentCodeId() != null) { + sql.SET("discount_agent_code_id = #{discountAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getUserId() != null) { sql.SET("user_id = #{userId,jdbcType=BIGINT}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index 8bf9ceb0..68729d2f 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -44,10 +44,10 @@ public interface HighOrderMapperExt { @Select({ "