dev-discount
袁野 4 years ago
commit 8a70dab029
  1. 27
      hai-cweb/src/main/java/com/cweb/config/SysConfig.java
  2. 74
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  3. 23
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  4. 3
      hai-cweb/src/main/java/com/cweb/controller/WechatController.java
  5. 9
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  6. 7
      hai-cweb/src/main/resources/dev/config.properties
  7. 31
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  8. 33
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  9. 17
      hai-service/src/main/java/com/hai/common/pay/entity/WeChatPayReqInfo.java
  10. 34
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  11. 19
      hai-service/src/main/java/com/hai/dao/HighUserCouponMapper.java
  12. 14
      hai-service/src/main/java/com/hai/dao/HighUserCouponSqlProvider.java
  13. 16
      hai-service/src/main/java/com/hai/entity/HighUserCoupon.java
  14. 60
      hai-service/src/main/java/com/hai/entity/HighUserCouponExample.java
  15. 21
      hai-service/src/main/java/com/hai/model/HighUserCouponModel.java
  16. 7
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  17. 14
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  18. 51
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  19. 5
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  20. 2
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java
  21. 51
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  22. 77
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java
  23. 2
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java

@ -15,6 +15,9 @@ public class SysConfig {
private String wxAppSecret; private String wxAppSecret;
private String wxApiKey; private String wxApiKey;
private String wxMchId; private String wxMchId;
private String wxMchAppId;
private String wxSubAppId;
private String wxSubMchId;
private String wxUnifiedOrderUrl; private String wxUnifiedOrderUrl;
private String couponCodePath; private String couponCodePath;
private String notifyUrl; private String notifyUrl;
@ -82,4 +85,28 @@ public class SysConfig {
public void setCouponCodePath(String couponCodePath) { public void setCouponCodePath(String couponCodePath) {
this.couponCodePath = couponCodePath; this.couponCodePath = couponCodePath;
} }
public String getWxSubMchId() {
return wxSubMchId;
}
public void setWxSubMchId(String wxSubMchId) {
this.wxSubMchId = wxSubMchId;
}
public String getWxMchAppId() {
return wxMchAppId;
}
public void setWxMchAppId(String wxMchAppId) {
this.wxMchAppId = wxMchAppId;
}
public String getWxSubAppId() {
return wxSubAppId;
}
public void setWxSubAppId(String wxSubAppId) {
this.wxSubAppId = wxSubAppId;
}
} }

@ -9,6 +9,9 @@ import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.BsCompany; import com.hai.entity.BsCompany;
import com.hai.entity.HighUserCoupon;
import com.hai.model.HighUserCouponModel;
import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.*; import com.hai.service.*;
@ -39,15 +42,9 @@ public class HighCouponController {
@Autowired @Autowired
private UserCenter userCenter; private UserCenter userCenter;
@Resource
private HighMerchantService highMerchantService;
@Resource @Resource
private HighCouponService highCouponService; private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@Resource @Resource
private BsCompanyService bsCompanyService; private BsCompanyService bsCompanyService;
@ -55,7 +52,7 @@ public class HighCouponController {
private HighCouponCodeService highCouponCodeService; private HighCouponCodeService highCouponCodeService;
@Resource @Resource
private HighApproveService highApproveService; private HighUserCouponService highUserCouponService;
@RequestMapping(value="/getCouponList",method = RequestMethod.GET) @RequestMapping(value="/getCouponList",method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -104,4 +101,67 @@ public class HighCouponController {
} }
} }
@RequestMapping(value = "/getUserCouponList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户卡卷")
public ResponseData getUserCouponList(@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String,Object> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId());
PageHelper.startPage(pageNum, pageSize);
List<HighUserCouponModel> list = highUserCouponService.getUserCouponList(map);
for (HighUserCouponModel highUserCouponModel : list) {
highUserCouponModel.setHighCouponModel(highCouponService.getCouponById(highUserCouponModel.getCouponId()));
}
return ResponseMsgUtil.success(new PageInfo<>());
} catch (Exception e) {
log.error("HighCouponController --> getUserCouponList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getUserCouponDetail", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户卡卷")
public ResponseData getUserCouponDetail(@RequestParam(name = "couponId", required = true) Long couponId,
HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
HighUserCoupon coupon = highUserCouponService.getUserCoupon(userInfoModel.getHighUser().getId(), couponId);
if (coupon == null) {
log.error("HighCouponController --> getUserCouponDetail() error!", "卡卷库存数量不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "");
}
Map<String, Object> map = new HashMap<>();
map.put("highUserCoupon", "coupon");
map.put("couponInfo", highCouponService.getCouponById(coupon.getCouponId()));
map.put("couponCodeInfo", highCouponCodeService.getCouponCodeById(coupon.getCouponCodeId()));
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("HighCouponController --> getUserCouponDetail() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -106,7 +106,6 @@ public class HighOrderController {
childOrder.setGoodsImg(coupon.getCouponImg()); childOrder.setGoodsImg(coupon.getCouponImg());
childOrder.setGoodsSpecName("默认"); childOrder.setGoodsSpecName("默认");
childOrder.setGoodsPrice(coupon.getDiscountPrice()); childOrder.setGoodsPrice(coupon.getDiscountPrice());
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
} }
if (childOrder.getGoodsType() == 2) { if (childOrder.getGoodsType() == 2) {
@ -124,15 +123,15 @@ public class HighOrderController {
childOrder.setGoodsName(user.getName()); childOrder.setGoodsName(user.getName());
childOrder.setGoodsImg(user.getHeaderImg()); childOrder.setGoodsImg(user.getHeaderImg());
childOrder.setGoodsSpecName("默认"); childOrder.setGoodsSpecName("默认");
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
} }
childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString())));
childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是 childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是
childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
childOrder.setPraiseStatus(0); childOrder.setPraiseStatus(0);
// 累计订单价格 // 累计订单价格
totalPrice.add(childOrder.getTotalPrice()); totalPrice = totalPrice.add(childOrder.getTotalPrice());
} }
highOrder.setOrderNo("HF" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); highOrder.setOrderNo("HF" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
@ -145,7 +144,7 @@ public class HighOrderController {
highOrderService.insertOrder(highOrder); highOrderService.insertOrder(highOrder);
return ResponseMsgUtil.success("操作成功"); return ResponseMsgUtil.success(highOrder);
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController -> addOrder() error!",e); log.error("HighOrderController -> addOrder() error!",e);
@ -168,6 +167,22 @@ public class HighOrderController {
} }
} }
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "取消订单")
public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
highOrderService.cancelOrder(orderId);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET) @RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET)
@ResponseBody @ResponseBody

@ -135,6 +135,7 @@ public class WechatController {
user.setOpenId(openId); user.setOpenId(openId);
user.setRegTime(new Date()); user.setRegTime(new Date());
user.setStatus(1); user.setStatus(1);
user.setGold(0);
user.setPhone(phoneNoInfo.getPurePhoneNumber()); user.setPhone(phoneNoInfo.getPurePhoneNumber());
highUserService.insertUser(user); highUserService.insertUser(user);
} else { } else {
@ -154,6 +155,7 @@ public class WechatController {
} catch (Exception e) { } catch (Exception e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }
@ -189,6 +191,7 @@ public class WechatController {
user.setOpenId(openId); user.setOpenId(openId);
user.setRegTime(new Date()); user.setRegTime(new Date());
user.setStatus(1); user.setStatus(1);
user.setGold(0);
user.setHeaderImg(userInfo.getAvatarUrl()); user.setHeaderImg(userInfo.getAvatarUrl());
user.setName(userInfo.getNickName()); user.setName(userInfo.getNickName());
highUserService.insertUser(user); highUserService.insertUser(user);

@ -128,9 +128,12 @@ public class OrderController {
String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");
int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue();
WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo();
weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxAppId()); //公众号id weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
weChatPayReqInfo.setOpenid(openId);
weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号
weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号
weChatPayReqInfo.setOpenid(openId);
weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
@ -141,7 +144,7 @@ public class OrderController {
// weChatPayReqInfo.setAttach(map.get("orderScene").toString()); //附加数据,区分订单类型 // weChatPayReqInfo.setAttach(map.get("orderScene").toString()); //附加数据,区分订单类型
Map<String,String> payMap = new HashMap<>(); Map<String,String> payMap = new HashMap<>();
payMap.put("app_id",SysConst.getSysConfig().getWxAppId()); payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId());
payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); payMap.put("api_key",SysConst.getSysConfig().getWxApiKey());
payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl());
SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);

@ -1,8 +1,13 @@
# 微信配置 # 微信配置
wxAppId=wx8d49e2f83025229d wxAppId=wx8d49e2f83025229d
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df
wxApiKey=HfkjWxPayHaiShengGuang0123456789 wxApiKey=HfkjWxPayHaiShengGuang0123456789
wxMchId=1603942866 wxMchAppId=wx637bd6f7314daa46
wxMchId=1289663601
wxSubAppId=wx8d49e2f83025229d
wxSubMchId=1603942866
wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder
notifyUrl=https://hsgcs.dctpay.com//crest/wechatpay/notify notifyUrl=https://hsgcs.dctpay.com//crest/wechatpay/notify

@ -0,0 +1,31 @@
package com.hai.schedule;
import com.hai.entity.HighUserCoupon;
import com.hai.service.HighUserCouponService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import java.util.List;
/**
* @Auther: 胡锐
* @Description: 卡卷定时任务
* @Date: 2021/3/27 15:39
*/
@Configuration
public class HighCouponSchedule {
@Resource
private HighUserCouponService highUserCouponService;
// @Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
@Scheduled(cron = "0 0 0 * * ?") //每天 凌晨0点执行
public void certification() {
List<HighUserCoupon> userCoupons = highUserCouponService.getOverdueCoupon();
for (HighUserCoupon highUserCoupon : userCoupons) {
highUserCoupon.setStatus(0); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponService.updateUserCoupon(highUserCoupon);
}
}
}

@ -0,0 +1,33 @@
package com.hai.schedule;
import com.hai.entity.HighOrder;
import com.hai.service.HighOrderService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import javax.annotation.Resource;
import javax.xml.ws.RespectBinding;
import java.util.List;
/**
* @Auther: 胡锐
* @Description: 订单定时任务
* @Date: 2021/3/27 15:41
*/
@Configuration
public class HighOrderSchedule {
@Resource
private HighOrderService highOrderService;
@Scheduled(cron="0 0/1 * * * ?") //每1分钟执行一次
public void certification() {
List<HighOrder> orderList = highOrderService.getCloseOrder();
if (orderList != null && orderList.size() > 0) {
for (HighOrder order : orderList) {
highOrderService.cancelOrder(order.getId());
}
}
}
}

@ -9,6 +9,8 @@ public class WeChatPayReqInfo implements Serializable {
private static final long serialVersionUID = -7642108447915413137L; private static final long serialVersionUID = -7642108447915413137L;
private String appid; // 公众号id 必填 private String appid; // 公众号id 必填
private String mch_id; // 商户号 必填 private String mch_id; // 商户号 必填
private String sub_appid; // 微信支付分配的子商户号 必填
private String sub_mch_id; // 微信支付分配的子商户号 必填
private String nonce_str; // 随机字符串 必填 private String nonce_str; // 随机字符串 必填
private String sign; // 签名 必填 private String sign; // 签名 必填
private String device_info; // 设备号 可以为终端设备号(门店号或收银设备ID),PC网页或公众号内支付可以传"WEB" private String device_info; // 设备号 可以为终端设备号(门店号或收银设备ID),PC网页或公众号内支付可以传"WEB"
@ -202,4 +204,19 @@ public class WeChatPayReqInfo implements Serializable {
this.scene_info = scene_info; this.scene_info = scene_info;
} }
public String getSub_mch_id() {
return sub_mch_id;
}
public void setSub_mch_id(String sub_mch_id) {
this.sub_mch_id = sub_mch_id;
}
public String getSub_appid() {
return sub_appid;
}
public void setSub_appid(String sub_appid) {
this.sub_appid = sub_appid;
}
} }

@ -1,7 +1,41 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.HighOrder;
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扩展类 * mapper扩展类
*/ */
public interface HighOrderMapperExt { public interface HighOrderMapperExt {
@Select({"SELECT * FROM high_order ho WHERE TIMESTAMPDIFF(MINUTE,ho.create_time,SYSDATE()) > 15 AND ho.order_status = 1"})
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="mem_id", property="memId", jdbcType=JdbcType.BIGINT),
@Result(column="mem_name", property="memName", jdbcType=JdbcType.VARCHAR),
@Result(column="pay_model", property="payModel", jdbcType=JdbcType.INTEGER),
@Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER),
@Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER),
@Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_real_price", property="payRealPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_serial_no", property="paySerialNo", jdbcType=JdbcType.VARCHAR),
@Result(column="order_status", property="orderStatus", jdbcType=JdbcType.INTEGER),
@Result(column="total_price", property="totalPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="pay_time", property="payTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="remarks", property="remarks", 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<HighOrder> getCloseOrder();
} }

@ -41,14 +41,14 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Insert({ @Insert({
"insert into high_user_coupon (merchant_id, coupon_id, ", "insert into high_user_coupon (merchant_id, coupon_id, ",
"user_id, coupon_code_id, ", "user_id, coupon_code_id, ",
"use_end_time, `status`, ", "create_time, use_end_time, ",
"ext_1, ext_2, ext_3, ", "`status`, ext_1, ext_2, ",
"ext_4)", "ext_3, ext_4)",
"values (#{merchantId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ", "values (#{merchantId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, ",
"#{userId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ", "#{userId,jdbcType=BIGINT}, #{couponCodeId,jdbcType=BIGINT}, ",
"#{useEndTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ", "#{createTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ",
"#{ext4,jdbcType=VARCHAR})" "#{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighUserCoupon record); int insert(HighUserCoupon record);
@ -64,6 +64,7 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@ -75,8 +76,8 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Select({ @Select({
"select", "select",
"id, merchant_id, coupon_id, user_id, coupon_code_id, use_end_time, `status`, ", "id, merchant_id, coupon_id, user_id, coupon_code_id, create_time, use_end_time, ",
"ext_1, ext_2, ext_3, ext_4", "`status`, ext_1, ext_2, ext_3, ext_4",
"from high_user_coupon", "from high_user_coupon",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@ -86,6 +87,7 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT), @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
@Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR), @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@ -110,6 +112,7 @@ public interface HighUserCouponMapper extends HighUserCouponMapperExt {
"coupon_id = #{couponId,jdbcType=BIGINT},", "coupon_id = #{couponId,jdbcType=BIGINT},",
"user_id = #{userId,jdbcType=BIGINT},", "user_id = #{userId,jdbcType=BIGINT},",
"coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"use_end_time = #{useEndTime,jdbcType=TIMESTAMP},", "use_end_time = #{useEndTime,jdbcType=TIMESTAMP},",
"`status` = #{status,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},",
"ext_1 = #{ext1,jdbcType=VARCHAR},", "ext_1 = #{ext1,jdbcType=VARCHAR},",

@ -44,6 +44,10 @@ public class HighUserCouponSqlProvider {
sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}"); sql.VALUES("coupon_code_id", "#{couponCodeId,jdbcType=BIGINT}");
} }
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUseEndTime() != null) { if (record.getUseEndTime() != null) {
sql.VALUES("use_end_time", "#{useEndTime,jdbcType=TIMESTAMP}"); sql.VALUES("use_end_time", "#{useEndTime,jdbcType=TIMESTAMP}");
} }
@ -82,6 +86,7 @@ public class HighUserCouponSqlProvider {
sql.SELECT("coupon_id"); sql.SELECT("coupon_id");
sql.SELECT("user_id"); sql.SELECT("user_id");
sql.SELECT("coupon_code_id"); sql.SELECT("coupon_code_id");
sql.SELECT("create_time");
sql.SELECT("use_end_time"); sql.SELECT("use_end_time");
sql.SELECT("`status`"); sql.SELECT("`status`");
sql.SELECT("ext_1"); sql.SELECT("ext_1");
@ -125,6 +130,10 @@ public class HighUserCouponSqlProvider {
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
} }
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUseEndTime() != null) { if (record.getUseEndTime() != null) {
sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}"); sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}");
} }
@ -162,6 +171,7 @@ public class HighUserCouponSqlProvider {
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
sql.SET("user_id = #{record.userId,jdbcType=BIGINT}"); sql.SET("user_id = #{record.userId,jdbcType=BIGINT}");
sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}"); sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}"); sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
@ -194,6 +204,10 @@ public class HighUserCouponSqlProvider {
sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code_id = #{couponCodeId,jdbcType=BIGINT}");
} }
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUseEndTime() != null) { if (record.getUseEndTime() != null) {
sql.SET("use_end_time = #{useEndTime,jdbcType=TIMESTAMP}"); sql.SET("use_end_time = #{useEndTime,jdbcType=TIMESTAMP}");
} }

@ -38,6 +38,11 @@ public class HighUserCoupon implements Serializable {
*/ */
private Long couponCodeId; private Long couponCodeId;
/**
* 创建时间
*/
private Date createTime;
/** /**
* 使用截止时间 * 使用截止时间
*/ */
@ -98,6 +103,14 @@ public class HighUserCoupon implements Serializable {
this.couponCodeId = couponCodeId; this.couponCodeId = couponCodeId;
} }
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUseEndTime() { public Date getUseEndTime() {
return useEndTime; return useEndTime;
} }
@ -163,6 +176,7 @@ public class HighUserCoupon implements Serializable {
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUseEndTime() == null ? other.getUseEndTime() == null : this.getUseEndTime().equals(other.getUseEndTime())) && (this.getUseEndTime() == null ? other.getUseEndTime() == null : this.getUseEndTime().equals(other.getUseEndTime()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1())) && (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
@ -180,6 +194,7 @@ public class HighUserCoupon implements Serializable {
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUseEndTime() == null) ? 0 : getUseEndTime().hashCode()); result = prime * result + ((getUseEndTime() == null) ? 0 : getUseEndTime().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode()); result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
@ -200,6 +215,7 @@ public class HighUserCoupon implements Serializable {
sb.append(", couponId=").append(couponId); sb.append(", couponId=").append(couponId);
sb.append(", userId=").append(userId); sb.append(", userId=").append(userId);
sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponCodeId=").append(couponCodeId);
sb.append(", createTime=").append(createTime);
sb.append(", useEndTime=").append(useEndTime); sb.append(", useEndTime=").append(useEndTime);
sb.append(", status=").append(status); sb.append(", status=").append(status);
sb.append(", ext1=").append(ext1); sb.append(", ext1=").append(ext1);

@ -425,6 +425,66 @@ public class HighUserCouponExample {
return (Criteria) this; 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<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> 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 andUseEndTimeIsNull() { public Criteria andUseEndTimeIsNull() {
addCriterion("use_end_time is null"); addCriterion("use_end_time is null");
return (Criteria) this; return (Criteria) this;

@ -0,0 +1,21 @@
package com.hai.model;
import com.hai.entity.HighUserCoupon;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/27 17:19
*/
public class HighUserCouponModel extends HighUserCoupon {
private HighCouponModel highCouponModel;
public HighCouponModel getHighCouponModel() {
return highCouponModel;
}
public void setHighCouponModel(HighCouponModel highCouponModel) {
this.highCouponModel = highCouponModel;
}
}

@ -57,6 +57,13 @@ public interface HighCouponCodeService {
**/ **/
HighCouponCode getCouponCodeBySalesCode(String code); HighCouponCode getCouponCodeBySalesCode(String code);
/**
* @Author 胡锐
* @Description 根据id 查询
* @Date 2021/3/27 17:52
**/
HighCouponCode getCouponCodeById(Long id);
/** /**
* *
* @Title: getStockCountByCoupon * @Title: getStockCountByCoupon

@ -61,6 +61,13 @@ public interface HighOrderService {
**/ **/
List<HighOrder> getOrderList(Map<String,Object> map); List<HighOrder> getOrderList(Map<String,Object> map);
/**
* @Author 胡锐
* @Description 查询需要关闭的订单列表
* @Date 2021/3/27 15:43
**/
List<HighOrder> getCloseOrder();
/** /**
* @Author 胡锐 * @Author 胡锐
* @Description 子订单完成 * @Description 子订单完成
@ -68,4 +75,11 @@ public interface HighOrderService {
**/ **/
void childOrderComplete(Long childOrderId); void childOrderComplete(Long childOrderId);
/**
* @Author 胡锐
* @Description 取消订单
* @Date 2021/3/27 15:50
**/
void cancelOrder(Long orderId);
} }

@ -0,0 +1,51 @@
package com.hai.service;
import com.hai.entity.HighUserCoupon;
import com.hai.model.HighUserCouponModel;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description: 用户的卡卷
* @Date: 2021/3/27 16:06
*/
public interface HighUserCouponService {
/**
* @Author 胡锐
* @Description 增加
* @Date 2021/3/27 16:08
**/
void insertUserCoupon(HighUserCoupon highUserCoupon);
/**
* @Author 胡锐
* @Description 修改
* @Date 2021/3/27 16:08
**/
void updateUserCoupon(HighUserCoupon highUserCoupon);
/**
* @Author 胡锐
* @Description 获取已到期的卡卷
* @Date 2021/3/27 16:09
**/
List<HighUserCoupon> getOverdueCoupon();
/**
* @Author 胡锐
* @Description 查询用户列表
* @Date 2021/3/27 17:21
**/
List<HighUserCouponModel> getUserCouponList(Map<String,Object> map);
/**
* @Author 胡锐
* @Description 根据用户id 卡卷id查询
* @Date 2021/3/27 17:42
**/
HighUserCoupon getUserCoupon(Long userId, Long couponId);
}

@ -107,6 +107,11 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
return null; return null;
} }
@Override
public HighCouponCode getCouponCodeById(Long id) {
return highCouponCodeMapper.selectByPrimaryKey(id);
}
@Override @Override
public Integer getStockCountByCoupon(Long couponId) { public Integer getStockCountByCoupon(Long couponId) {
HighCouponCodeExample example = new HighCouponCodeExample(); HighCouponCodeExample example = new HighCouponCodeExample();

@ -286,7 +286,7 @@ public class HighCouponServiceImpl implements HighCouponService {
HighCouponModel model = new HighCouponModel(); HighCouponModel model = new HighCouponModel();
BeanUtils.copyProperties(highCoupon, model); BeanUtils.copyProperties(highCoupon, model);
// 查询有效库存 // 查询有效库存
model.setSalesCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId())); model.setStockCount(highCouponCodeService.getStockCountByCoupon(highCoupon.getId()));
// 查询赠送卡卷列表 // 查询赠送卡卷列表
List<HighCouponHandselModel> coupon = highCouponHandselService.getHandselListByCoupon(highCoupon.getId()); List<HighCouponHandselModel> coupon = highCouponHandselService.getHandselListByCoupon(highCoupon.getId());

@ -8,6 +8,7 @@ import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator; import com.hai.common.utils.IDGenerator;
import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighOrderMapper; import com.hai.dao.HighOrderMapper;
import com.hai.dao.HighOrderMapperExt;
import com.hai.dao.HighUserCouponMapper; import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.HighCouponHandselModel; import com.hai.model.HighCouponHandselModel;
@ -21,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Auther: 胡锐 * @Auther: 胡锐
@ -37,6 +35,9 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource @Resource
private HighOrderMapper highOrderMapper; private HighOrderMapper highOrderMapper;
@Resource
private HighOrderMapperExt highOrderMapperExt;
@Resource @Resource
private HighChildOrderMapper highChildOrderMapper; private HighChildOrderMapper highChildOrderMapper;
@ -60,7 +61,8 @@ public class HighOrderServiceImpl implements HighOrderService {
public void insertOrder(HighOrder highOrder) throws Exception { public void insertOrder(HighOrder highOrder) throws Exception {
highOrderMapper.insert(highOrder); highOrderMapper.insert(highOrder);
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { for (int i = 0; i < highOrder.getHighChildOrderList().size();i++) {
HighChildOrder childOrder = highOrder.getHighChildOrderList().get(i);
childOrder.setOrderId(highOrder.getId()); childOrder.setOrderId(highOrder.getId());
highChildOrderMapper.insert(childOrder); highChildOrderMapper.insert(childOrder);
@ -76,7 +78,8 @@ public class HighOrderServiceImpl implements HighOrderService {
highCouponCodeService.updateCouponCode(list.get(0)); highCouponCodeService.updateCouponCode(list.get(0));
// 生成二维码 // 生成二维码
String qrCodeUrl = "/home/project/hsg/filesystem/couponCode/"+DateUtil.date2String(new Date(),"yyyyMMddHHmmss")+".png"; //String qrCodeUrl = "/home/project/hsg/filesystem/couponCode/"+DateUtil.date2String(new Date(),"yyyyMMddHHmmss")+".png";
String qrCodeUrl = "F:\\"+DateUtil.date2String(new Date(),"yyyyMMddHHmmss")+".png";
QRCodeGenerator.generateQRCodeImage(list.get(0).getSalesCode(), 350, 350, qrCodeUrl); QRCodeGenerator.generateQRCodeImage(list.get(0).getSalesCode(), 350, 350, qrCodeUrl);
childOrder.setExt1(qrCodeUrl); childOrder.setExt1(qrCodeUrl);
highChildOrderMapper.updateByPrimaryKey(childOrder); highChildOrderMapper.updateByPrimaryKey(childOrder);
@ -87,13 +90,13 @@ public class HighOrderServiceImpl implements HighOrderService {
if (handselListByCoupon != null && handselListByCoupon.size() > 0) { if (handselListByCoupon != null && handselListByCoupon.size() > 0) {
for (HighCouponHandsel highCouponHandsel : handselListByCoupon) { for (HighCouponHandsel highCouponHandsel : handselListByCoupon) {
// 查询卡卷信息 // 查询卡卷信息
HighCouponModel coupon = highCouponService.getCouponById(highCouponHandsel.getId()); HighCouponModel coupon = highCouponService.getCouponById(highCouponHandsel.getHandselCouponId());
if (coupon == null) { if (coupon == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, "");
} }
// 查询赠送卡卷 是否有库存,没有就不赠送 // 查询赠送卡卷 是否有库存,没有就不赠送
if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) { if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) > 0) {
HighChildOrder highChildOrder = new HighChildOrder(); HighChildOrder highChildOrder = new HighChildOrder();
highChildOrder.setOrderId(highOrder.getId()); highChildOrder.setOrderId(highOrder.getId());
highChildOrder.setGoodsType(1); highChildOrder.setGoodsType(1);
@ -103,7 +106,7 @@ public class HighOrderServiceImpl implements HighOrderService {
highChildOrder.setGoodsSpecName("默认"); highChildOrder.setGoodsSpecName("默认");
highChildOrder.setGoodsPrice(new BigDecimal(0)); highChildOrder.setGoodsPrice(new BigDecimal(0));
highChildOrder.setSaleCount(1); highChildOrder.setSaleCount(1);
highChildOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); highChildOrder.setTotalPrice(new BigDecimal(0));
highChildOrder.setGiveawayType(true); // 是否是赠品 0:否 1:是 highChildOrder.setGiveawayType(true); // 是否是赠品 0:否 1:是
highChildOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 highChildOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
highChildOrder.setPraiseStatus(0); highChildOrder.setPraiseStatus(0);
@ -140,6 +143,7 @@ public class HighOrderServiceImpl implements HighOrderService {
if (highChildOrder.getGoodsType() == 1) { if (highChildOrder.getGoodsType() == 1) {
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code); highCouponCodeService.updateCouponCode(code);
// 卡卷关联用户 // 卡卷关联用户
@ -148,6 +152,7 @@ public class HighOrderServiceImpl implements HighOrderService {
highUserCoupon.setCouponId(code.getCouponId()); highUserCoupon.setCouponId(code.getCouponId());
highUserCoupon.setUserId(highOrder.getMemId()); highUserCoupon.setUserId(highOrder.getMemId());
highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setCreateTime(new Date());
highUserCoupon.setUseEndTime(code.getUseEndTime()); highUserCoupon.setUseEndTime(code.getUseEndTime());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon); highUserCouponMapper.insert(highUserCoupon);
@ -226,6 +231,11 @@ public class HighOrderServiceImpl implements HighOrderService {
return highOrderMapper.selectByExample(example); return highOrderMapper.selectByExample(example);
} }
@Override
public List<HighOrder> getCloseOrder() {
return highOrderMapperExt.getCloseOrder();
}
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public void childOrderComplete(Long childOrderId) { public void childOrderComplete(Long childOrderId) {
@ -245,4 +255,27 @@ public class HighOrderServiceImpl implements HighOrderService {
highOrderMapper.updateByPrimaryKey(order); highOrderMapper.updateByPrimaryKey(order);
} }
} }
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void cancelOrder(Long orderId) {
HighOrder order = getOrderById(orderId);
if (order != null) {
order.setOrderStatus(5); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
order.setCancelTime(new Date());
for (HighChildOrder highChildOrder : order.getHighChildOrderList()) {
// 商品类型 1:卡卷 2:金币充值
if (highChildOrder.getGoodsType() == 1) {
// 查询卡卷详情
HighCouponCode couponCode = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
couponCode.setChildOrderId(null);
couponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(couponCode);
}
highChildOrder.setChildOrdeStatus(5); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
}
updateOrder(order);
}
}
} }

@ -0,0 +1,77 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSON;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserCouponExample;
import com.hai.model.HighUserCouponModel;
import com.hai.service.HighUserCouponService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/27 16:10
*/
@Service("highUserCouponService")
public class HighUserCouponServiceImpl implements HighUserCouponService {
@Resource
private HighUserCouponMapper highUserCouponMapper;
@Override
public void insertUserCoupon(HighUserCoupon highUserCoupon) {
highUserCouponMapper.insert(highUserCoupon);
}
@Override
public void updateUserCoupon(HighUserCoupon highUserCoupon) {
highUserCouponMapper.updateByPrimaryKey(highUserCoupon);
}
@Override
public List<HighUserCoupon> getOverdueCoupon() {
HighUserCouponExample example = new HighUserCouponExample();
example.createCriteria().andStatusEqualTo(1).andUseEndTimeGreaterThanOrEqualTo(new Date());
return highUserCouponMapper.selectByExample(example);
}
@Override
public List<HighUserCouponModel> getUserCouponList(Map<String, Object> map) {
HighUserCouponExample example = new HighUserCouponExample();
HighUserCouponExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map, "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
example.setOrderByClause("create_time desc");
List<HighUserCoupon> highUserCoupons = highUserCouponMapper.selectByExample(example);
if (highUserCoupons != null && highUserCoupons.size() > 0) {
return JSON.parseArray(JSON.toJSONString(highUserCoupons), HighUserCouponModel.class);
}
return new ArrayList<>();
}
@Override
public HighUserCoupon getUserCoupon(Long userId, Long couponId) {
HighUserCouponExample example = new HighUserCouponExample();
example.createCriteria().andUserIdEqualTo(userId).andCouponIdEqualTo(couponId);
List<HighUserCoupon> coupons = highUserCouponMapper.selectByExample(example);
if (coupons != null && coupons.size() > 0) {
return coupons.get(0);
}
return null;
}
}

@ -67,6 +67,7 @@ public class GoodsOrderServiceImpl implements PayService {
highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId());
code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
code.setReceiveTime(new Date());
highCouponCodeService.updateCouponCode(code); highCouponCodeService.updateCouponCode(code);
// 卡卷关联用户 // 卡卷关联用户
@ -75,6 +76,7 @@ public class GoodsOrderServiceImpl implements PayService {
highUserCoupon.setCouponId(code.getCouponId()); highUserCoupon.setCouponId(code.getCouponId());
highUserCoupon.setUserId(order.getMemId()); highUserCoupon.setUserId(order.getMemId());
highUserCoupon.setCouponCodeId(code.getId()); highUserCoupon.setCouponCodeId(code.getId());
highUserCoupon.setCreateTime(new Date());
highUserCoupon.setUseEndTime(code.getUseEndTime()); highUserCoupon.setUseEndTime(code.getUseEndTime());
highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
highUserCouponMapper.insert(highUserCoupon); highUserCouponMapper.insert(highUserCoupon);

Loading…
Cancel
Save