Commit 35745bc1 by caiyt

修复优化优惠券联调过程中遇到的问题及新增其他接口

parent c4a74f35
......@@ -10,10 +10,14 @@ import com.soss.common.exception.ServiceException;
import com.soss.framework.web.service.TokenService;
import com.soss.system.domain.Order;
import com.soss.system.domain.OrderDetail;
import com.soss.system.domain.vo.CouponVo;
import com.soss.system.service.ICouponUserService;
import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.service.impl.WechatMessageServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -34,14 +38,14 @@ public class AppController extends BaseController {
private OrderServiceImpl orderService;
@Autowired
private WechatMessageServiceImpl wechatMessageService;
@Autowired
private ICouponUserService couponUserService;
@RequestMapping("/getMyOrder")
public TableDataInfo getMyOrder(HttpServletRequest request){
public TableDataInfo getMyOrder(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
if(loginUser ==null){
throw new ServiceException("请先登录");
if (loginUser == null) {
throw new ServiceException("请先登录");
}
String openId = loginUser.getOpenId();
startPage();
......@@ -59,6 +63,7 @@ public class AppController extends BaseController {
Map<String,String> info = orderService.getMyFristOrder(openId,shopId);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/getWaitTine")
public AjaxResult getWaitTime(@RequestBody String body){
JSONObject jsonObject = JSONObject.parseObject(body);
......@@ -77,26 +82,48 @@ public class AppController extends BaseController {
String info = orderService.getWaitTime(order);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/getWaitTineByOrderId")
public AjaxResult getWaitTineByOrderId( Long orderId){
String info = orderService.getWaitTimeByOrderId(orderId);
return AjaxResult.success("操作成功",info);
}
@RequestMapping("/refundOrder")
public AjaxResult refundOrder(String orderId){
return AjaxResult.success(orderService.refundOrder(orderId));
}
@RequestMapping("/getNextOrder")
public AjaxResult getNextOrder(String orderId,String shopId){
return AjaxResult.success(orderService.getNextOrder(orderId,shopId));
public AjaxResult getNextOrder(String orderId, String shopId) {
return AjaxResult.success(orderService.getNextOrder(orderId, shopId));
}
@RequestMapping("/getMessageCount")
public AjaxResult getMessageCount(HttpServletRequest request){
public AjaxResult getMessageCount(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
return AjaxResult.success("", wechatMessageService.getMessageCount(loginUser.getOpenId()));
}
@GetMapping("/coupon/available/count")
@ApiOperation("查询用户可用优惠券数量")
public AjaxResult getUserAvailableCouponCnt(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
return AjaxResult.success("",wechatMessageService.getMessageCount(loginUser.getOpenId()));
if (loginUser == null) {
throw new ServiceException("请先登录");
}
int userAvailableCouponCnt = couponUserService.getUserAvailableCouponCnt(loginUser.getUserId());
return AjaxResult.success(userAvailableCouponCnt);
}
@GetMapping("/coupon/available/list")
@ApiOperation("查询用户可用优惠券列表")
public TableDataInfo listUserAvailableCoupon(HttpServletRequest request) {
LoginUser loginUser = tokenService.getLoginUser(request);
if (loginUser == null) {
throw new ServiceException("请先登录");
}
List<CouponVo> userAvailableCouponCnt = couponUserService.listUserAvailableCoupon(loginUser.getUserId());
return getDataTable(userAvailableCouponCnt);
}
}
package com.soss.web.controller.coffee;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.Goods;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.soss.common.annotation.Log;
import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType;
import com.soss.system.domain.Goods;
import com.soss.system.domain.Shop;
import com.soss.system.service.IShopService;
import com.soss.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 店铺Controller
......@@ -128,18 +131,47 @@ public class ShopController extends BaseController
/**
* 获取有店铺的城市
*
* @return
*/
@GetMapping("/getShopCity")
public AjaxResult getShopCity(){
public AjaxResult getShopCity() {
return AjaxResult.success(shopService.getShopCity());
}
@GetMapping("/area/tree")
public AjaxResult getShopAreaTree() {
Map<String, Map<String, Map<String, List<Shop>>>> shopAreaTree = shopService.getShopAreaTree();
Map<String, Object> treeMap = new HashMap<>(shopAreaTree);
return AjaxResult.success(buildShopAreaTree(treeMap));
}
private List<Map<String, Object>> buildShopAreaTree(Map<String, Object> dataSourceMap) {
List<Map<String, Object>> nodeMapList = new ArrayList<>();
dataSourceMap.forEach((key, val) -> {
Map<String, Object> nodeMap = new HashMap<>();
nodeMapList.add(nodeMap);
nodeMap.put("value", key);
if (val instanceof Map) {
nodeMap.put("children", buildShopAreaTree((Map) val));
} else if (val instanceof List) {
List<Map<String, String>> shopMapList = new ArrayList<>();
((List) val).forEach(shop -> {
Map<String, String> shopMap = new HashMap<>();
shopMap.put("value", String.valueOf(((Shop) shop).getId()));
shopMap.put("label", ((Shop) shop).getName());
shopMapList.add(shopMap);
});
nodeMap.put("children", shopMapList);
}
});
return nodeMapList;
}
@GetMapping("/goodslist")
public TableDataInfo list(String goodsName,String category,Long shopId)
{
public TableDataInfo list(String goodsName, String category, Long shopId) {
startPage();
List<Goods> list = shopService.selectGoodsList(goodsName,category,shopId);
List<Goods> list = shopService.selectGoodsList(goodsName, category, shopId);
return getDataTable(list);
}
......
......@@ -4,13 +4,15 @@ package com.soss.web.controller.coupon;
import com.soss.common.annotation.Log;
import com.soss.common.core.domain.AjaxResult;
import com.soss.common.enums.BusinessType;
import com.soss.system.domain.po.CouponPo;
import com.soss.system.service.ICouponUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
......@@ -32,7 +34,7 @@ public class CouponUserController {
*/
@PreAuthorize("@ss.hasPermi('coupon:user:give')")
@Log(title = "赠送优惠券", businessType = BusinessType.INSERT)
@PutMapping("/{userId}/{userPhone}/{couponId}")
@GetMapping("/{userId}/{userPhone}/{couponId}")
@ApiOperation("赠送优惠券")
public AjaxResult giveUserCoupon(@PathVariable Long userId, @PathVariable String userPhone, @PathVariable Integer couponId) {
couponUserService.giveUserCoupon(userId, userPhone, couponId);
......
package com.soss.common.enums;
public enum CouponUserState {
DEFAULT(0, "默认"),
USED(1, "已使用"),
EXPIRED(2, "已过期"),
FORBIDDEN(3, "已禁用");
private Integer state;
private String desc;
CouponUserState(Integer state, String desc) {
this.state = state;
this.desc = desc;
}
public Integer getState() {
return state;
}
public static String getDesc(Integer state) {
for (CouponUserState couponUserStat : CouponUserState.values()) {
if (couponUserStat.state.equals(state)) {
return couponUserStat.desc;
}
}
return null;
}
}
package com.soss.common.utils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.lang.management.ManagementFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.*;
import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;
/**
* 时间工具类
*
......@@ -164,7 +159,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
}
public static LocalDateTime addDaysAndGetBegin(LocalDateTime targetTime, int days) {
targetTime.plusDays(days);
return targetTime.toLocalDate().atTime(0, 0, 0, 0);
return targetTime.plusDays(days).toLocalDate().atTime(0, 0, 0, 0);
}
public static LocalDateTime addDaysAndGetEnd(LocalDateTime targetTime, int days) {
return targetTime.plusDays(days).toLocalDate().atTime(23, 59, 59, 999999999);
}
}
......@@ -63,16 +63,10 @@ public class CouponRule extends BaseEntity {
private String goodsIds;
/**
* 领取开始时间
* 可领取时间时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
/**
* 领取截止时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
private LocalDateTime receivableTime;
/**
* 使用绝对开始时间
......
package com.soss.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.soss.common.annotation.Excel;
import com.soss.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
* 店铺对象 shop
......@@ -149,27 +150,33 @@ public class Shop extends BaseEntity
private Integer salesVolume;
public Shop() {
super();
}
public void setId(long id)
{
public Shop(long id, String code, String name) {
this.id = id;
this.code = code;
this.name = name;
}
public long getId()
{
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
public void setName(String name)
{
public void setName(String name) {
this.name = name;
}
public String getName()
{
public String getName() {
return name;
}
public void setCode(String code)
{
public void setCode(String code) {
this.code = code;
}
......
......@@ -40,13 +40,9 @@ public class CouponPo {
@ApiModelProperty("可用店铺ID列表")
private Integer[] shopIds;
@ApiModelProperty("领取开始时间")
@ApiModelProperty("可领取时间时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
@ApiModelProperty("领取截止时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
private LocalDateTime receivableTime;
@ApiModelProperty("使用绝对开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
package com.soss.system.mapper;
import com.soss.system.domain.CouponUser;
import com.soss.system.domain.vo.CouponVo;
import org.apache.ibatis.annotations.Param;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 用户领取优惠券记录表 Mapper 接口
......@@ -21,6 +25,13 @@ public interface CouponUserMapper {
int getCouponReceiveCount(@Param("couponId") Integer couponId);
/**
* 查询用户的优惠券信息
*
* @return
*/
CouponUser getUserCouponById(@Param("id") Integer id);
/**
* 保存用户领取优惠券记录
*
* @param couponUser
......@@ -35,4 +46,22 @@ public interface CouponUserMapper {
* @return
*/
int updateCouponUser(CouponUser couponUser);
/**
* 查询用户可用优惠券数量
*
* @param userId
* @param nowTime
* @return
*/
int getUserAvailableCouponCnt(@Param("userId") Long userId, @Param("nowTime") LocalDateTime nowTime);
/**
* 查询用户可用优惠券列表
*
* @param userId
* @param nowTime
* @return
*/
List<CouponVo> listUserAvailableCoupon(@Param("userId") Long userId, @Param("nowTime") LocalDateTime nowTime);
}
package com.soss.system.mapper;
import java.util.List;
import com.soss.system.domain.Shop;
import java.util.List;
/**
* 店铺Mapper接口
*
......@@ -13,15 +14,22 @@ public interface ShopMapper
{
/**
* 查询店铺
*
*
* @param id 店铺主键
* @return 店铺
*/
public Shop selectShopById(String id);
/**
* 查询所有的店铺
*
* @return 店铺集合
*/
List<Shop> selectAllShop();
/**
* 查询店铺列表
*
*
* @param shop 店铺
* @return 店铺集合
*/
......@@ -29,7 +37,7 @@ public interface ShopMapper
/**
* 新增店铺
*
*
* @param shop 店铺
* @return 结果
*/
......
package com.soss.system.service;
import com.soss.system.domain.vo.CouponVo;
import java.util.List;
/**
* <p>
* 用户领取优惠券记录表 服务类
......@@ -11,4 +15,10 @@ package com.soss.system.service;
public interface ICouponUserService {
void giveUserCoupon(Long userId, String phone, Integer couponId);
void receiveCoupon(Long userId, Integer id);
int getUserAvailableCouponCnt(Long userId);
List<CouponVo> listUserAvailableCoupon(Long userId);
}
package com.soss.system.service;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.soss.system.domain.Goods;
......@@ -75,6 +76,8 @@ public interface IShopService
List<String> getShopCity();
Map<String, Map<String, Map<String, List<Shop>>>> getShopAreaTree();
String offGoods(JSONObject body);
......
......@@ -124,10 +124,15 @@ public class CouponServiceImpl implements ICouponService {
ruleDesc = "满" + couponPo.getPriceLimit() + "元";
}
}
Assert.isTrue(couponPo.getDaysLimit() > 0 && couponPo.getUserLimit() != null,
Assert.notNull(couponPo.getDaysLimit(), "用户可领取次数限制还未设置");
Assert.isTrue(couponPo.getDaysLimit() == 0
|| (couponPo.getDaysLimit() > 0 && couponPo.getUserLimit() != null && couponPo.getUserLimit() > 0),
"用户可领取次数限制还未设置完全");
Assert.notNull(couponPo.getUseStartTime(), "优惠券的绝对有效时间还未设置");
Assert.notNull(couponPo.getUseEndTime(), "优惠券的绝对有效时间还未设置");
if (couponPo.getReceivableTime() != null && couponPo.getReceivableTime().isAfter(couponPo.getUseStartTime())) {
throw new ServiceException("优惠券的可领取时间要早于或等于优惠券的绝对有效时间的起始时间");
}
Assert.isTrue((couponPo.getCategoryIds() != null && couponPo.getCategoryIds().length > 0)
|| (couponPo.getGoodsIds() != null && couponPo.getGoodsIds().length > 0), "商品范围还未设置");
couponPo.couponUseLimitCheck();
......@@ -150,10 +155,26 @@ public class CouponServiceImpl implements ICouponService {
couponRule.setDesc(ruleDesc);
couponRule.setCategoryIds(Arrays.stream(couponPo.getCategoryIds()).map(String::valueOf).collect(Collectors.joining(",")));
couponRule.setGoodsIds(Arrays.stream(couponPo.getGoodsIds()).map(String::valueOf).collect(Collectors.joining(",")));
couponRule.setProvince(String.join(",", couponPo.getProvince()));
couponRule.setCity(String.join(",", couponPo.getCity()));
couponRule.setArea(String.join(",", couponPo.getArea()));
couponRule.setShopIds(Arrays.stream(couponPo.getShopIds()).map(String::valueOf).collect(Collectors.joining(",")));
if (couponPo.getProvince() == null || couponPo.getProvince().length == 0) {
couponRule.setProvince("");
} else {
couponRule.setProvince(String.join(",", couponPo.getProvince()));
}
if (couponPo.getCity() == null || couponPo.getCity().length == 0) {
couponRule.setCity("");
} else {
couponRule.setCity(String.join(",", couponPo.getCity()));
}
if (couponPo.getArea() == null || couponPo.getArea().length == 0) {
couponRule.setArea("");
} else {
couponRule.setArea(String.join(",", couponPo.getArea()));
}
if (couponPo.getShopIds() == null || couponPo.getShopIds().length == 0) {
couponRule.setShopIds("");
} else {
couponRule.setShopIds(Arrays.stream(couponPo.getShopIds()).map(String::valueOf).collect(Collectors.joining(",")));
}
if (saveFlag) {
couponRule.setCreatedAt(now);
}
......
......@@ -7,6 +7,7 @@ import com.soss.common.utils.DateUtils;
import com.soss.system.domain.Coupon;
import com.soss.system.domain.CouponRule;
import com.soss.system.domain.CouponUser;
import com.soss.system.domain.vo.CouponVo;
import com.soss.system.mapper.CouponMapper;
import com.soss.system.mapper.CouponRuleMapper;
import com.soss.system.mapper.CouponUserMapper;
......@@ -14,9 +15,11 @@ import com.soss.system.mapper.SysUserMapper;
import com.soss.system.service.ICouponUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
/**
......@@ -56,17 +59,69 @@ public class CouponUserServiceImpl implements ICouponUserService {
couponUser.setUserName(user.getUserName());
couponUser.setUserPhone(user.getPhonenumber());
couponUser.setCouponId(couponId);
couponUser.setExpiredTime(this.getCouponExpiredTime(couponRule, now));
couponUser.setReceiveTime(now);
if (couponRule.getRelativeTime() != null && couponRule.getRelativeTime() > 0) {
LocalDateTime expiredTime = DateUtils.addDaysAndGetBegin(now, couponRule.getRelativeTime() + 1);
expiredTime = expiredTime.isBefore(couponRule.getUseEndTime()) ? expiredTime : couponRule.getUseEndTime();
couponUser.setExpiredTime(expiredTime);
} else {
couponUser.setExpiredTime(couponRule.getUseEndTime());
}
couponUser.setSource("give");
couponUser.setType(2);
couponUser.setCreatedAt(now);
couponUser.setUpdatedAt(now);
couponUserMapper.insertCouponUser(couponUser);
}
@Override
@Transactional
public void receiveCoupon(Long userId, Integer id) {
CouponUser couponUser = couponUserMapper.getUserCouponById(id);
Assert.notNull(couponUser, "未查询到匹配记录[id=" + id + "]");
Assert.isTrue(couponUser.getUserId().equals(userId), "该券与当前用户信息不符");
LocalDateTime now = LocalDateTime.now();
Coupon coupon = couponMapper.selectCouponById(couponUser.getCouponId());
Assert.notNull(coupon, "未查询到匹配的优惠券信息[id=" + couponUser.getCouponId() + "]");
CouponRule couponRule = couponRuleMapper.selectCouponRuleById(coupon.getRuleId());
Assert.notNull(couponRule, "未查询到匹配的优惠券规则信息[id=" + coupon.getRuleId() + "]");
if (couponRule.getReceivableTime() != null && couponRule.getReceivableTime().isAfter(now)) {
throw new ServiceException("该券还未到可领取的时间:" + DateUtils.dateTimeNow());
}
if (couponRule.getUseEndTime().isBefore(now)) {
throw new ServiceException("该券已失效");
}
couponUser.setExpiredTime(this.getCouponExpiredTime(couponRule, now));
couponUser.setReceiveTime(now);
couponUser.setUpdatedAt(now);
couponUserMapper.updateCouponUser(couponUser);
}
private LocalDateTime getCouponExpiredTime(CouponRule couponRule, LocalDateTime now) {
LocalDateTime expiredTime;
if (couponRule.getRelativeTime() != null && couponRule.getRelativeTime() > 0) {
LocalDateTime expireComputerStartTime = couponRule.getUseStartTime().isAfter(now) ? couponRule.getUseStartTime() : now;
expiredTime = DateUtils.addDaysAndGetEnd(expireComputerStartTime, couponRule.getRelativeTime());
expiredTime = expiredTime.isBefore(couponRule.getUseEndTime()) ? expiredTime : couponRule.getUseEndTime();
} else {
expiredTime = couponRule.getUseEndTime();
}
return expiredTime;
}
/**
* 查询用户可用优惠券数量
*
* @param userId
* @return
*/
@Override
public int getUserAvailableCouponCnt(Long userId) {
return couponUserMapper.getUserAvailableCouponCnt(userId, LocalDateTime.now());
}
/**
* 查询用户可用优惠券列表
*
* @param userId
* @return
*/
@Override
public List<CouponVo> listUserAvailableCoupon(Long userId) {
return couponUserMapper.listUserAvailableCoupon(userId, LocalDateTime.now());
}
}
package com.soss.system.service.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.core.domain.AjaxResult;
......@@ -14,17 +8,20 @@ import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*;
import com.soss.system.domain.vo.orderTaking.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IShopService;
import com.soss.system.mapper.*;
import com.soss.system.service.IShopService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 店铺Service业务层处理
*
*
* @author zxq
* @date 2022-04-28
*/
......@@ -326,18 +323,27 @@ public class ShopServiceImpl implements IShopService
}
@Override
public Map<String, Map<String, Map<String, List<Shop>>>> getShopAreaTree() {
List<Shop> shops = shopMapper.selectAllShop();
return shops.stream().collect(Collectors.groupingBy(Shop::getProvince, LinkedHashMap::new,
Collectors.groupingBy(Shop::getCity, LinkedHashMap::new,
Collectors.groupingBy(Shop::getZone, LinkedHashMap::new,
Collectors.mapping(shop -> new Shop(shop.getId(), shop.getCode(), shop.getName()), Collectors.toList())))));
}
@Override
public String offGoods(JSONObject body) {
Long shopId = body.getLong("shopId");
String string = body.getString("goodsIds");
List<String> goodsIds = JSONObject.parseArray(string, String.class);
shopGoodsSkuMapper.deleteByGoodsIds(shopId,goodsIds);
shopGoodsMapper.deleteByShopIdGoods(shopId,goodsIds);
shopRecommendMapper.deleteByShopIdGoods(shopId,goodsIds);
shopGoodsSkuMapper.deleteByGoodsIds(shopId, goodsIds);
shopGoodsMapper.deleteByShopIdGoods(shopId, goodsIds);
shopRecommendMapper.deleteByShopIdGoods(shopId, goodsIds);
Machine machine = new Machine();
machine.setShopId(shopId);
List<Machine> machines = machineMapper.selectMachineList(machine);
if(!machines.isEmpty()){
Machine machine1 =machines .get(0);
if (!machines.isEmpty()) {
Machine machine1 = machines.get(0);
updateApplication(machine1.getCode());
}
return null;
......
......@@ -12,8 +12,7 @@
<result column="city" property="city"/>
<result column="area" property="area"/>
<result column="shop_ids" property="shopIds"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="receivable_time" property="receivableTime"/>
<result column="use_start_time" property="useStartTime"/>
<result column="use_end_time" property="useEndTime"/>
<result column="relative_time" property="relativeTime"/>
......@@ -55,8 +54,7 @@
<if test="city != null and city != ''">city,</if>
<if test="area != null and area != ''">area,</if>
<if test="shopIds != null and shopIds != ''">shop_ids,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="receivableTime != null">receivable_time,</if>
<if test="useStartTime != null">use_start_time,</if>
<if test="useEndTime != null">use_end_time,</if>
<if test="relativeTime != null">relative_time,</if>
......@@ -81,8 +79,7 @@
<if test="city != null and city != ''">#{city},</if>
<if test="area != null and area != ''">#{area},</if>
<if test="shopIds != null and shopIds != ''">#{shopIds},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="receivableTime != null">#{receivableTime},</if>
<if test="useStartTime != null">#{useStartTime},</if>
<if test="useEndTime != null">#{useEndTime},</if>
<if test="relativeTime != null">#{relativeTime},</if>
......@@ -111,8 +108,7 @@
<if test="city != null and city != ''">city = #{city},</if>
<if test="area != null and area != ''">area = #{area},</if>
<if test="shopIds != null and shopIds != ''">shop_ids = #{shopIds},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="receivableTime != null">receivable_time = #{receivableTime},</if>
<if test="useStartTime != null">use_start_time = #{useStartTime},</if>
<if test="useEndTime != null">use_end_time = #{useEndTime},</if>
<if test="relativeTime != null">relative_time = #{relativeTime},</if>
......
......@@ -26,7 +26,37 @@
where coupon_id = #{couponId}
</select>
<insert id="insertCouponUser" parameterType="com.soss.system.domain.CouponUser" useGeneratedKeys="true" keyProperty="id">
<select id="getUserAvailableCouponCnt" resultType="java.lang.Integer">
select count(*)
<include refid="selectUserAvailableCoupon"/>
</select>
<select id="listUserAvailableCoupon" resultType="com.soss.system.domain.vo.CouponVo">
select cu.id, cc.`type`, cc.name categoryName, cr.name ruleName, cr.`desc` ruleDesc, c.name, cr.use_start_time
useStartTime, cu.expired_time useEndTime, cc.`desc` categoryDesc, cr.category_ids categoryIds, cr.goods_ids
goodsIds, cr.province, cr.city, cr.area, cr.shop_ids shopIds
<include refid="selectUserAvailableCoupon"/>
</select>
<sql id="selectUserAvailableCoupon">
from coupon_user cu
left join coupon c on cu.coupon_id = c.id
left join coupon_category cc on c.category_id = cc.id
left join coupon_rule cr on c.rule_id = cr.id
where cu.user_id = #{userId} and cr.use_start_time &lt; #{nowTime} and cu.expired_time > #{nowTime}
and cu.state = ${@com.soss.common.enums.CouponUserState @DEFAULT.getState}
</sql>
<select id="getUserAvailableCouponList" resultMap="BaseResultMap">
</select>
<select id="getUserCouponInfo" resultMap="BaseResultMap">
select * from coupon_user where id = #{id}
</select>
<insert id="insertCouponUser" parameterType="com.soss.system.domain.CouponUser" useGeneratedKeys="true"
keyProperty="id">
insert into coupon_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
......
......@@ -16,26 +16,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="address" column="address" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="zone" column="zone" />
<result property="state" column="state" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="isDefault" column="is_default" />
<result property="zone" column="zone"/>
<result property="state" column="state"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
<result property="isDefault" column="is_default"/>
</resultMap>
<sql id="selectShopVo">
select id, name, code, lng, lat, remarks, start_time, end_time, address, province, city, zone, state, created_at, updated_at, is_default from shop
</sql>
<select id="selectAllShop" resultMap="ShopResult">
select id, name, code, province, city, zone from shop
</select>
<select id="selectShopList" parameterType="Shop" resultMap="ShopResult">
select * from shop s left join machine m on s.id =m.shop_id
<where>
<if test="name != null and name != ''"> and s.name like concat('%', #{name}, '%')</if>
<if test="code != null and code != ''"> and s.code = #{code}</if>
<if test="lng != null and lng != ''"> and s.lng = #{lng}</if>
<if test="lat != null and lat != ''"> and s.lat = #{lat}</if>
<if test="remarks != null and remarks != ''"> and s.remarks = #{remarks}</if>
<if test="startTime != null and startTime != ''"> and s.start_time = #{startTime}</if>
<where>
<if test="name != null and name != ''">and s.name like concat('%', #{name}, '%')</if>
<if test="code != null and code != ''">and s.code = #{code}</if>
<if test="lng != null and lng != ''">and s.lng = #{lng}</if>
<if test="lat != null and lat != ''">and s.lat = #{lat}</if>
<if test="remarks != null and remarks != ''">and s.remarks = #{remarks}</if>
<if test="startTime != null and startTime != ''">and s.start_time = #{startTime}</if>
<if test="endTime != null and endTime != ''"> and s.end_time = #{endTime}</if>
<if test="address != null and address != ''"> and s.address = #{address}</if>
<if test="province != null and province != ''"> and s.province = #{province}</if>
......
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