| @@ -3,6 +3,7 @@ package com.iformall.domain.po.tt; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @@ -58,6 +59,9 @@ public class TtOrder extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否入账",name="isRecorded") | |||
| private Integer isRecorded; | |||
| public String getPaymentStr() { | |||
| return payment != null ? new BigDecimal(payment).divide(new BigDecimal(100)).toPlainString() : paymentStr; | |||
| @@ -68,7 +72,13 @@ public class TtOrder extends TenantEntity { | |||
| private String paymentStr; | |||
| @TableField(exist = false) | |||
| protected TtCoupon ttCoupon; | |||
| protected TtCUser cUser; | |||
| @TableField(exist = false) | |||
| protected TtCoupon coupon; | |||
| @TableField(exist = false) | |||
| protected WxMerchant merchant; | |||
| @TableField(exist = false) | |||
| protected List<Integer> statusS; | |||
| @@ -8,6 +8,7 @@ import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.domain.vo.*; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -19,4 +20,6 @@ public interface TtOrderMapper extends CommonMapper<TtOrder, Long> { | |||
| List<TtOrder> findCList(TtOrder record); | |||
| Integer findListCount(TtOrder orderQ); | |||
| int updateExpire(@Param("expireDate")Date expireDate,@Param("orderStatus") Integer orderStatus); | |||
| } | |||
| @@ -17,11 +17,7 @@ import com.iformall.douyin.pay.preOrder.DouYinCreatePreOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.TtCUserService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.tt.TtCouponService; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -42,7 +38,13 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| private TtOrderMapper ttOrderMapper; | |||
| @Autowired | |||
| private TtCouponService ttCouponService; | |||
| private TtCouponMapper couponMapper; | |||
| @Autowired | |||
| private TtCUserMapper cUserMapper; | |||
| @Autowired | |||
| private WxMerchantMapper merchantMapper; | |||
| // @Autowired | |||
| // private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @@ -92,7 +94,7 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| // logger.info("会员权益被锁定:cUserId:" + cUserId); | |||
| // return new ResultData(ErrorCode.MEMBER_IS_LOCKED); | |||
| // } | |||
| TtCoupon coupon = ttCouponService.getById(couponId); | |||
| TtCoupon coupon = couponMapper.selectById(couponId); | |||
| if (null == coupon) { | |||
| return new ResultData(ErrorCode.TTCOUPON_IS_EMPTY); | |||
| } | |||
| @@ -128,7 +130,7 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| order.setCreateDate(now); | |||
| order.setUpdateDate(now); | |||
| ttOrderMapper.insert(order); | |||
| ttCouponService.addSellCount(coupon.getId()); | |||
| couponMapper.addSellCount(coupon.getId()); | |||
| return new ResultData(order); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -183,8 +185,9 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| if(memberId != null && !ttOrder.getCUserId().equals(memberId)){ | |||
| return null; | |||
| } | |||
| TtCoupon coupon = ttCouponService.detail(ttOrder.getProductId()); | |||
| ttOrder.setTtCoupon(coupon); | |||
| ttOrder.setCUser(cUserMapper.selectById(ttOrder.getCUserId())); | |||
| ttOrder.setCoupon(couponMapper.selectById(ttOrder.getProductId())); | |||
| ttOrder.setMerchant(merchantMapper.selectById(ttOrder.getMerchantId())); | |||
| return ttOrder; | |||
| } | |||
| @@ -217,7 +220,7 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| if(payAcount == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| TtCoupon coupon = ttCouponService.getById(order.getProductId()); | |||
| TtCoupon coupon = couponMapper.selectById(order.getProductId()); | |||
| if (!coupon.getStatus().equals(EnumTtCouponStatus.TTCOUPON_STATUS_SHELFING.getCode())) { | |||
| logger.error("券已经下架了>>>" + order.getProductId()); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF); | |||
| @@ -20,6 +20,7 @@ | |||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="is_recorded" jdbcType="INTEGER" property="isRecorded"/> | |||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||
| <result column="phone" jdbcType="VARCHAR" property="phone"/> | |||
| @@ -29,7 +30,7 @@ | |||
| <sql id="allColumns"> | |||
| o.`id`,o.`tenant_id`,o.`parent_tenant_id`,o.`c_user_id`,o.`product_id`,o.`type`,o.`way`,o.`payment_type`,o.`payment`, | |||
| o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`, | |||
| o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`,o.`is_recorded`, | |||
| u.`nick_name`,u.`phone`, | |||
| o.`product_title`,o.`product_pic`,o.`product_sale_price`, | |||
| m.`name` author,m.`img_url` author_pic | |||
| @@ -240,4 +241,9 @@ | |||
| </if> | |||
| </select> | |||
| <update id="updateExpire" parameterType="java.util.HashMap"> | |||
| update tt_order set order_status = #{orderStatus},update_date = now() | |||
| where orderStatus=0 and create_date < #{expireDate} | |||
| </update> | |||
| </mapper> | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.Date; | |||
| @Component | |||
| public class TtOrderExpiringSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final int PRESS_TIME_OUT = 30 * 60 * 1000; //必须30分钟内支付 | |||
| @Autowired | |||
| TtOrderMapper ttOrderMapper; | |||
| @Scheduled(cron = "0 */1 * * * *?") // 每1分钟检查一次 | |||
| public void orderExpireSchedule() { | |||
| Date now = new Date(); | |||
| Date expireDate = new Date(now.getTime() - PRESS_TIME_OUT ); | |||
| int count = ttOrderMapper.updateExpire(expireDate,EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| if(count > 0){ | |||
| logger.info("订单过期"+count+"个"); | |||
| } | |||
| } | |||
| } | |||