Commit 2357c337 by 吕明尚

查询可用优惠卷完成

parent 87fdcdb2
......@@ -47,7 +47,7 @@ public class QPController {
//用户销券接口
@GetMapping("/reverseconsumeByUser")
public R reverseconsumeByUser(String code, String appDealId) {
return R.ok(qpService.reverseconsumeByUser(code, appDealId));
public R reverseconsumeByUser(Long id) {
return R.ok(qpService.reverseconsumeByUser(id));
}
}
......@@ -38,14 +38,12 @@ public class SCoupon extends BaseEntity
private Date endDate;
/** 有效开始时段 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效开始时段", width = 30, dateFormat = "yyyy-MM-dd")
private Date validStartTime;
@Excel(name = "有效开始时段", width = 30, dateFormat = "HH:mm")
private String validStartTime;
/** 有效结束时段 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "有效结束时段", width = 30, dateFormat = "yyyy-MM-dd")
private Date validEndTime;
@Excel(name = "有效结束时段", width = 30, dateFormat = "HH:mm")
private String validEndTime;
//门店类型
@Excel(name = "门店类型(1:标准店,2:外卖店,3:酒店,4:其他)")
......
......@@ -18,5 +18,5 @@ public interface QPService {
String consumeByUser(String code, int count);
String reverseconsumeByUser(String code, String appDealId);
String reverseconsumeByUser(Long id);
}
......@@ -11,9 +11,11 @@ import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptPrepare;
import com.dianping.openapi.sdk.api.tuangou.TuangouReceiptReverseConsume;
import com.dianping.openapi.sdk.api.tuangou.entity.*;
import com.dianping.openapi.sdk.httpclient.DefaultOpenAPIClient;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.common.utils.uuid.UUID;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SCoupon;
......@@ -22,7 +24,11 @@ import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.QPService;
import java.util.List;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Service
public class QPServiceImpl implements QPService {
......@@ -72,6 +78,8 @@ public class QPServiceImpl implements QPService {
sConsumerCoupon.setPlatformType("2");
sConsumerCoupon.setStartDate(sCoupon.getStartDate());
sConsumerCoupon.setEndDate(item.getReceiptEndDate());
sConsumerCoupon.setCouponTimeStart(sCoupon.getValidStartTime());
sConsumerCoupon.setCouponTimeEnd(sCoupon.getValidEndTime());
sConsumerCoupon.setCreateBy(String.valueOf(user.getId()));
isConsumerCouponService.insertSConsumerCoupon(sConsumerCoupon);
});
......@@ -79,9 +87,24 @@ public class QPServiceImpl implements QPService {
}
@Override
public String reverseconsumeByUser(String code, String appDealId) {
TuangouReceiptGetConsumedReponseEntity getconsumed = getconsumed(code);
return null;
public String reverseconsumeByUser(Long id) {
SConsumerCoupon byId = isConsumerCouponService.getById(id);
if (byId == null) {
throw new RuntimeException("未找到对应的券码");
}
if(StringUtils.isBlank(byId.getCouponCode())){
throw new RuntimeException("未找到对应的券码");
}
TuangouReceiptGetConsumedReponseEntity getconsumed = getconsumed(byId.getCouponCode());
if (getconsumed == null) {
throw new RuntimeException("未找到对应的券码");
}
List<TuangouReceiptReverseConsumeResponseEntity> reverseconsume = reverseconsume(byId.getCouponCode(), getconsumed.getApp_shop_id());
if (reverseconsume == null) {
throw new RuntimeException("未找到对应的券码");
}
isConsumerCouponService.removeById(id);
return "销卷成功";
}
/**
......
......@@ -70,7 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSCouponVo"/>
where id = #{id}
</select>
<select id="selectSCouponByName" resultType="share.system.domain.SCoupon">
<select id="selectSCouponByName" resultMap="SCouponResult">
<include refid="selectSCouponVo"/>
where name = #{name}
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment