dev-discount
胡锐 4 years ago
commit acde32e916
  1. 12
      hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java
  2. 31
      hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java
  3. 33
      hai-schedule/src/main/java/com/hai/schedule/HighOrderSchedule.java
  4. 4
      hai-service/src/main/java/com/hai/dao/HighCouponCodeMapperExt.java
  5. 34
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  6. 14
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  7. 35
      hai-service/src/main/java/com/hai/service/HighUserCouponService.java
  8. 31
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  9. 40
      hai-service/src/main/java/com/hai/service/impl/HighUserCouponServiceImpl.java

@ -39,24 +39,12 @@ public class HighCouponController {
@Autowired
private UserCenter userCenter;
@Resource
private HighMerchantService highMerchantService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@Resource
private BsCompanyService bsCompanyService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighApproveService highApproveService;
@RequestMapping(value="/getCouponList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "卡卷列表")

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

@ -14,7 +14,7 @@ public interface HighCouponCodeMapperExt {
@Insert({
"<script>",
"insert into high_coupon_code (coupon_id, merchant_id, ",
"order_id, sales_code, ",
"child_order_id, sales_code, ",
"sales_end_time, use_end_time, ",
"create_time, receive_time, ",
"consume_time, `status`, ",
@ -24,7 +24,7 @@ public interface HighCouponCodeMapperExt {
"<foreach collection='list' item='item' index='index' separator=','>",
"(#{item.couponId,jdbcType=BIGINT}, " +
"#{item.merchantId,jdbcType=BIGINT}," +
"#{item.orderId,jdbcType=BIGINT}, " +
"#{item.childOrderId,jdbcType=BIGINT}, " +
"#{item.salesCode,jdbcType=VARCHAR}, ",
"#{item.salesEndTime,jdbcType=TIMESTAMP}," +
"#{item.useEndTime,jdbcType=TIMESTAMP}, ",

@ -1,7 +1,41 @@
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扩展类
*/
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();
}

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

@ -0,0 +1,35 @@
package com.hai.service;
import com.hai.entity.HighUserCoupon;
import java.util.List;
/**
* @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();
}

@ -8,6 +8,7 @@ import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighOrderMapper;
import com.hai.dao.HighOrderMapperExt;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.*;
import com.hai.model.HighCouponHandselModel;
@ -37,6 +38,9 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource
private HighOrderMapper highOrderMapper;
@Resource
private HighOrderMapperExt highOrderMapperExt;
@Resource
private HighChildOrderMapper highChildOrderMapper;
@ -226,6 +230,11 @@ public class HighOrderServiceImpl implements HighOrderService {
return highOrderMapper.selectByExample(example);
}
@Override
public List<HighOrder> getCloseOrder() {
return null;
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void childOrderComplete(Long childOrderId) {
@ -245,4 +254,26 @@ public class HighOrderServiceImpl implements HighOrderService {
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.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(couponCode);
}
highChildOrder.setChildOrdeStatus(5); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
}
updateOrder(order);
}
}
}

@ -0,0 +1,40 @@
package com.hai.service.impl;
import com.hai.dao.HighUserCouponMapper;
import com.hai.entity.HighUserCoupon;
import com.hai.entity.HighUserCouponExample;
import com.hai.service.HighUserCouponService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @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);
}
}
Loading…
Cancel
Save