Commit 968b4136 by caiyt

增加小程序下单的优惠券功能

parent 6abd00e5
...@@ -7,6 +7,7 @@ import com.soss.common.core.domain.AjaxResult; ...@@ -7,6 +7,7 @@ import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser; import com.soss.common.core.domain.model.LoginUser;
import com.soss.common.core.page.TableDataInfo; import com.soss.common.core.page.TableDataInfo;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.framework.web.service.TokenService; import com.soss.framework.web.service.TokenService;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.OrderDetail; import com.soss.system.domain.OrderDetail;
...@@ -16,7 +17,6 @@ import com.soss.system.service.ICouponUserService; ...@@ -16,7 +17,6 @@ import com.soss.system.service.ICouponUserService;
import com.soss.system.service.impl.AppServiceImpl; import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl; import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.service.impl.WechatMessageServiceImpl; import com.soss.system.service.impl.WechatMessageServiceImpl;
import com.soss.system.utils.CollectionUtil;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -26,8 +26,10 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,8 +26,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/app") @RequestMapping("/app")
...@@ -78,7 +80,7 @@ public class AppController extends BaseController { ...@@ -78,7 +80,7 @@ public class AppController extends BaseController {
order.setOrderDetails(orderDetails); order.setOrderDetails(orderDetails);
for(int i =0;i<goods.size();i++){ for(int i =0;i<goods.size();i++){
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
orderDetail.setGoodsId(goods.getJSONObject(i).getString("goodsId")); orderDetail.setGoodsId(goods.getJSONObject(i).getLong("goodsId"));
orderDetail.setNum(goods.getJSONObject(i).getString("num")); orderDetail.setNum(goods.getJSONObject(i).getString("num"));
orderDetails.add(orderDetail); orderDetails.add(orderDetail);
...@@ -127,16 +129,27 @@ public class AppController extends BaseController { ...@@ -127,16 +129,27 @@ public class AppController extends BaseController {
if (loginUser == null) { if (loginUser == null) {
throw new ServiceException("请先登录"); throw new ServiceException("请先登录");
} }
List<CouponVo> couponVoList = couponUserService.listCustAvailableCoupon(loginUser.getOpenId()); List<CouponVo> couponVoList = couponUserService.listCustAvailableCoupon(loginUser.getOpenId(), null);
couponVoList.forEach(couponVo -> {
couponVo.setCategoryIds(CollectionUtil.transStrToCodeList(couponVo.getCategoryIdStr()));
couponVo.setGoodsIds(CollectionUtil.transStrToLongList(couponVo.getGoodsIdStr()));
couponVo.setProvince(CollectionUtil.transStrToCodeList(couponVo.getProvinceStr()));
couponVo.setCity(CollectionUtil.transStrToCodeList(couponVo.getCityStr()));
couponVo.setArea(CollectionUtil.transStrToCodeList(couponVo.getAreaStr()));
couponVo.setShopIds(CollectionUtil.transStrToLongList(couponVo.getShopIdStr()));
});
couponRuleService.translateUseLimit(couponVoList); couponRuleService.translateUseLimit(couponVoList);
return getDataTable(couponVoList); return getDataTable(couponVoList);
} }
@GetMapping("/order/coupon/info")
@ApiOperation("下单页面查询用户可用优惠券信息")
public AjaxResult listUserAvailableCoupon(HttpServletRequest request, @RequestBody Order order) {
LoginUser loginUser = tokenService.getLoginUser(request);
if (loginUser == null) {
throw new ServiceException("请先登录");
}
List<CouponVo> couponVos = couponUserService.listCustAvailableCoupon(loginUser.getOpenId(), null);
couponUserService.resovleCouponFitable(couponVos, order);
couponRuleService.translateUseLimit(couponVos);
List<CouponVo> fitableList = couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc()))
.sorted(Comparator.comparing(CouponVo::getCouponAmount).reversed()).collect(Collectors.toList());
List<CouponVo> notFitableList = couponVos.stream().filter(couponVo -> !StringUtils.isEmpty(couponVo.getNotFitableDesc())).collect(Collectors.toList());
JSONObject result = new JSONObject();
result.put("fitable", fitableList);
result.put("notfitable", notFitableList);
return AjaxResult.success(result);
}
} }
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import com.soss.common.annotation.Log;
import com.soss.common.core.controller.BaseController; import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser; import com.soss.common.core.domain.model.LoginUser;
import com.soss.common.core.page.TableDataInfo; import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType;
import com.soss.common.utils.poi.ExcelUtil;
import com.soss.common.utils.spring.SpringUtils; import com.soss.common.utils.spring.SpringUtils;
import com.soss.framework.web.service.TokenService; import com.soss.framework.web.service.TokenService;
import com.soss.system.domain.Customer;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo; import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo; import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.service.ICustomerService; import com.soss.system.service.ICustomerService;
import com.soss.system.service.impl.CustomerServiceImpl; import com.soss.system.service.impl.CustomerServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
...@@ -60,19 +56,21 @@ public class CustomerController extends BaseController ...@@ -60,19 +56,21 @@ public class CustomerController extends BaseController
} }
/** /**
* 获取用户信息详细信息 * 获取用户信息详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:customer:query')") @PreAuthorize("@ss.hasPermi('system:customer:query')")
@GetMapping @GetMapping
public TableDataInfo getInfo(@RequestParam("id") String id,@RequestParam String status) public TableDataInfo getInfo(@RequestParam("id") String id, @RequestParam String status) {
{
startPage(); startPage();
List<Order> orders = customerService.selectCustomerById(id,status); List<Order> orders = customerService.selectCustomerById(id, status);
return getDataTable(orders); return getDataTable(orders);
} }
@PreAuthorize("@ss.hasPermi('system:customer:order-simple-stat')")
@GetMapping("/order-simple-stat/{custId}")
@ApiOperation("查询用户的下单基本信息:下单总量和下单总额")
public AjaxResult getCustOrderSimpleStat(@PathVariable String custId) {
return AjaxResult.success(customerService.getCustSimpleOrderStat(custId));
}
} }
package com.soss.web.controller.coffee; package com.soss.web.controller.coffee;
import java.util.List;
import com.soss.common.exception.ServiceException;
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.annotation.Log;
import com.soss.common.core.controller.BaseController; import com.soss.common.core.controller.BaseController;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.page.TableDataInfo;
import com.soss.common.enums.BusinessType; import com.soss.common.enums.BusinessType;
import com.soss.common.exception.ServiceException;
import com.soss.system.domain.Goods; import com.soss.system.domain.Goods;
import com.soss.system.service.IGoodsService; import com.soss.system.service.IGoodsService;
import com.soss.common.core.page.TableDataInfo; 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 java.util.List;
/** /**
* 商品Controller * 商品Controller
...@@ -66,15 +67,12 @@ public class GoodsController extends BaseController ...@@ -66,15 +67,12 @@ public class GoodsController extends BaseController
return AjaxResult.success(goodsService.offShop(goodsId,boo)); return AjaxResult.success(goodsService.offShop(goodsId,boo));
} }
/** /**
* 获取商品详细信息 * 获取商品详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:goods:query')") @PreAuthorize("@ss.hasPermi('system:goods:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) public AjaxResult getInfo(@PathVariable("id") Long id)
{ {
return AjaxResult.success(goodsService.selectGoodsById(id)); return AjaxResult.success(goodsService.selectGoodsById(id));
} }
...@@ -106,10 +104,18 @@ public class GoodsController extends BaseController ...@@ -106,10 +104,18 @@ public class GoodsController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:goods:remove')") @PreAuthorize("@ss.hasPermi('system:goods:remove')")
@Log(title = "商品", businessType = BusinessType.DELETE) @Log(title = "商品", businessType = BusinessType.DELETE)
@DeleteMapping("/remove") @DeleteMapping("/remove")
public AjaxResult remove(@RequestParam("goodsId") Long goodsId,@RequestParam(required = false) boolean boo) public AjaxResult remove(@RequestParam("goodsId") Long goodsId, @RequestParam(required = false) boolean boo) {
{ return AjaxResult.success(goodsService.deleteGoodsById(goodsId, boo));
return AjaxResult.success(goodsService.deleteGoodsById(goodsId,boo));
} }
/**
* 根据商品id获取sku列表
*/
@PreAuthorize("@ss.hasPermi('system:goods:sku:list')")
@GetMapping("/sku/list/{goodsId}")
@ApiOperation("根据商品id获取sku列表")
public AjaxResult getGoodsSkuList(@PathVariable("goodsId") Long goodsId) {
return AjaxResult.success(goodsService.getGoodsSkus(goodsId));
}
} }
...@@ -11,10 +11,14 @@ import com.soss.common.exception.ServiceException; ...@@ -11,10 +11,14 @@ import com.soss.common.exception.ServiceException;
import com.soss.framework.web.service.TokenService; import com.soss.framework.web.service.TokenService;
import com.soss.framework.web.service.WeixinServiceImpl; import com.soss.framework.web.service.WeixinServiceImpl;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.vo.CouponVo;
import com.soss.system.domain.vo.OrderQuery; import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.service.ICouponUserService;
import com.soss.system.service.impl.OrderServiceImpl; import com.soss.system.service.impl.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -36,6 +40,8 @@ public class OrderController extends BaseController { ...@@ -36,6 +40,8 @@ public class OrderController extends BaseController {
private TokenService tokenService; private TokenService tokenService;
@Autowired @Autowired
private WeixinServiceImpl weixinService; private WeixinServiceImpl weixinService;
@Autowired
private ICouponUserService couponUserService;
/** /**
* 查询订单列表 * 查询订单列表
...@@ -71,6 +77,33 @@ public class OrderController extends BaseController { ...@@ -71,6 +77,33 @@ public class OrderController extends BaseController {
public AjaxResult add(HttpServletRequest request, @RequestBody Order order) { public AjaxResult add(HttpServletRequest request, @RequestBody Order order) {
LoginUser loginUser = tokenService.getLoginUser(request); LoginUser loginUser = tokenService.getLoginUser(request);
AjaxResult result = check(order);
if (HttpStatus.SUCCESS != (int) result.get(result.CODE_TAG)) {
return result;
}
try {
orderService.checkBusinessTime(order.getShopId());
if (order.getCouponId() != null) {
List<CouponVo> couponVos = couponUserService.listCustAvailableCoupon(loginUser.getOpenId(), order.getCouponId());
if (CollectionUtils.isEmpty(couponVos)) {
return AjaxResult.error("未查询到匹配的优惠券信息");
}
couponUserService.resovleCouponFitable(couponVos, order);
CouponVo couponVo = couponVos.get(0);
String notFitableDesc = couponVo.getNotFitableDesc();
if (!StringUtils.isEmpty(notFitableDesc)) {
return AjaxResult.error(notFitableDesc);
}
order.setCouponAmount(couponVo.getCouponAmount().negate());
order.setPaidAmount(order.getAmount().add(order.getCouponAmount()));
order.getOrderDetails().forEach(orderDetail -> {
orderDetail.setCouponAmount(couponVo.getCouponAmountMap().get(orderDetail.getSkuId()).negate());
orderDetail.setRealAmount(orderDetail.getViewAmount().add(orderDetail.getCouponAmount()));
});
}
} catch (ServiceException e) {
return AjaxResult.error(e.getMessage());
}
AjaxResult ajaxResult = orderService.insertOrder(loginUser, order); AjaxResult ajaxResult = orderService.insertOrder(loginUser, order);
if (HttpStatus.SUCCESS != (int) ajaxResult.get(AjaxResult.CODE_TAG)) { if (HttpStatus.SUCCESS != (int) ajaxResult.get(AjaxResult.CODE_TAG)) {
......
...@@ -16,7 +16,7 @@ import com.soss.system.domain.po.CouponPo; ...@@ -16,7 +16,7 @@ import com.soss.system.domain.po.CouponPo;
import com.soss.system.domain.vo.CouponVo; import com.soss.system.domain.vo.CouponVo;
import com.soss.system.service.ICouponRuleService; import com.soss.system.service.ICouponRuleService;
import com.soss.system.service.ICouponService; import com.soss.system.service.ICouponService;
import com.soss.system.utils.CollectionUtil; import com.soss.system.utils.ArrayUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -85,12 +85,13 @@ public class CouponController extends BaseController { ...@@ -85,12 +85,13 @@ public class CouponController extends BaseController {
private void transLimitToArrStyle(CouponVo couponVo, CouponRule couponRule) { private void transLimitToArrStyle(CouponVo couponVo, CouponRule couponRule) {
BeanUtils.copyProperties(couponRule, couponVo, "name", "state", "categoryIds", "goodsIds", "province", "city", "area", "shopIds"); BeanUtils.copyProperties(couponRule, couponVo, "name", "state", "categoryIds", "goodsIds", "province", "city", "area", "shopIds");
couponVo.setCategoryIds(CollectionUtil.transStrToCodeList(couponRule.getCategoryIds())); couponVo.setCategoryIds(ArrayUtil.transStrToCodeList(couponRule.getCategoryIds()));
couponVo.setGoodsIds(CollectionUtil.transStrToLongList(couponRule.getGoodsIds())); couponVo.setGoodsIds(ArrayUtil.transStrToLongList(couponRule.getGoodsIds()));
couponVo.setProvince(CollectionUtil.transStrToCodeList(couponRule.getProvince())); couponVo.setProvince(ArrayUtil.transStrToCodeList(couponRule.getProvince()));
couponVo.setCity(CollectionUtil.transStrToCodeList(couponRule.getCity())); couponVo.setCity(ArrayUtil.transStrToCodeList(couponRule.getCity()));
couponVo.setArea(CollectionUtil.transStrToCodeList(couponRule.getArea())); couponVo.setArea(ArrayUtil.transStrToCodeList(couponRule.getArea()));
couponVo.setShopIds(CollectionUtil.transStrToLongList(couponRule.getShopIds())); couponVo.setShopIds(ArrayUtil.transStrToLongList(couponRule.getShopIds()));
couponVo.setWeekLimit(ArrayUtil.transStrToIntList(couponRule.getWeekLimit()));
} }
/** /**
......
package com.soss.common.enums; package com.soss.common.enums;
public enum CouponUserState { public enum CouponUserState {
DEFAULT(0, "默认"), EFFECTIVE(0, "有效"),
USED(1, "已使用"), USED(1, "被使用"),
EXPIRED(2, "已过期"), EXPIRED(2, "过期失效");
FORBIDDEN(3, "已禁用");
private Integer state; private Integer state;
private String desc; private String desc;
......
...@@ -34,9 +34,9 @@ public class MachineSericeImpl { ...@@ -34,9 +34,9 @@ public class MachineSericeImpl {
for (OrderDetail detail : orderDetails) { for (OrderDetail detail : orderDetails) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObjects.add(jsonObject); jsonObjects.add(jsonObject);
String skuId = detail.getSkuId(); Long skuId = detail.getSkuId();
String num = detail.getNum(); String num = detail.getNum();
String amount = detail.getAmount().stripTrailingZeros().toString(); String amount = detail.getViewAmount().stripTrailingZeros().toString();
String realAmount = detail.getRealAmount().stripTrailingZeros().toString(); String realAmount = detail.getRealAmount().stripTrailingZeros().toString();
jsonObject.put("skuID",skuId); jsonObject.put("skuID",skuId);
jsonObject.put("skuCount",num); jsonObject.put("skuCount",num);
......
package com.soss.system.constants;
public class SystemConstant {
/**
* 周几
*/
public final static String[] WEEK_DESC = new String[]{"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
}
package com.soss.system.domain; package com.soss.system.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; 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.annotation.Excel;
import com.soss.common.core.domain.BaseEntity; import com.soss.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* 由规格选项组合生成商品sku对象 goods_sku * 由规格选项组合生成商品sku对象 goods_sku
...@@ -14,6 +16,7 @@ import com.soss.common.core.domain.BaseEntity; ...@@ -14,6 +16,7 @@ import com.soss.common.core.domain.BaseEntity;
* @author zxq * @author zxq
* @date 2022-04-28 * @date 2022-04-28
*/ */
@Data
public class GoodsSku extends BaseEntity public class GoodsSku extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -47,80 +50,8 @@ public class GoodsSku extends BaseEntity ...@@ -47,80 +50,8 @@ public class GoodsSku extends BaseEntity
@Excel(name = "价格") @Excel(name = "价格")
private BigDecimal price; private BigDecimal price;
public BigDecimal getDiscount() {
return discount;
}
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
private BigDecimal discount; private BigDecimal discount;
public void setId(long id)
{
this.id = id;
}
public long getId()
{
return id;
}
public void setGoodsId(long goodsId)
{
this.goodsId = goodsId;
}
public long getGoodsId()
{
return goodsId;
}
public void setRuleList(String ruleList)
{
this.ruleList = ruleList;
}
public String getRuleList()
{
return ruleList;
}
public void setIsDeleted(String isDeleted)
{
this.isDeleted = isDeleted;
}
public String getIsDeleted()
{
return isDeleted;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
public void setPrice(BigDecimal price)
{
this.price = price;
}
public BigDecimal getPrice()
{
return price;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
package com.soss.system.domain; package com.soss.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.soss.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
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;
/** /**
* 订单对象 order * 订单对象 order
* *
* @author zxq * @author zxq
* @date 2022-04-28 * @date 2022-04-28
*/ */
public class Order implements Serializable @Data
{ public class Order implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 主键 */ /**
* 主键
*/
private Long id; private Long id;
/** 订单号 */ /**
* 订单号
*/
@Excel(name = "订单号") @Excel(name = "订单号")
private String orderNo; private String orderNo;
/** 订单顺序号 */ /**
* 订单顺序号
*/
@Excel(name = "订单顺序号") @Excel(name = "订单顺序号")
private String orderNum; private String orderNum;
/** 用户ID */ /**
* 用户ID
*/
@Excel(name = "用户ID") @Excel(name = "用户ID")
private String userId; private String userId;
/** 冗余 */ /**
* 冗余
*/
@Excel(name = "冗余") @Excel(name = "冗余")
private String userName; private String userName;
/** 冗余 */ /**
* 冗余
*/
@Excel(name = "冗余") @Excel(name = "冗余")
private String userPhone; private String userPhone;
/** 支付时间 */ /**
* 支付时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date payTime; private Date payTime;
/** 完成时间 */ /**
* 完成时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date finishTime; private Date finishTime;
/** 订单金额 */ /**
* 订单金额
*/
@Excel(name = "订单金额") @Excel(name = "订单金额")
private BigDecimal amount; private BigDecimal amount;
/** 商品数量 */ /**
* 优惠券id
*/
private Integer couponId;
/**
* 优惠金额
*/
@Excel(name = "优惠金额")
private BigDecimal couponAmount;
/**
* 实付金额
*/
@Excel(name = "实付金额")
private BigDecimal paidAmount;
/**
* 商品数量
*/
@Excel(name = "商品数量") @Excel(name = "商品数量")
private String goodsNum; private String goodsNum;
/** 取餐码 */ /**
* 取餐码
*/
@Excel(name = "取餐码") @Excel(name = "取餐码")
private String pickCode; private String pickCode;
/** 店铺ID */ /**
* 店铺ID
*/
@Excel(name = "店铺ID") @Excel(name = "店铺ID")
private String shopId; private String shopId;
/** 机器ID */ /**
* 机器ID
*/
@Excel(name = "机器ID") @Excel(name = "机器ID")
private String machineId; private String machineId;
/** 点单屏序号 */ /**
* 点单屏序号
*/
@Excel(name = "点单屏序号") @Excel(name = "点单屏序号")
private Integer source; private Integer source;
@Excel(name = "订单状态 0 未支付取消 1 未支付 2 已支付 3 待制作 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 8 支付后制作前取消 9 制作中取消 10 制作完成取消 11 已退款 12 部分退款 50 其他人工干预状态") @Excel(name = "订单状态 0 未支付取消 1 未支付 2 已支付 3 待制作 4 支付制作中 5 制作完成未取 6 取餐中 7 取餐完成 8 支付后制作前取消 9 制作中取消 10 制作完成取消 11 已退款 12 部分退款 50 其他人工干预状态")
private String state; private String state;
/** 创建时间 */ /**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt; private Date createdAt;
/** 更新时间 */ /**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt; private Date updatedAt;
private Shop shop; private Shop shop;
public Shop getShop() { private List<OrderDetail> orderDetails;
return shop;
}
public void setShop(Shop shop) {
this.shop = shop;
}
private List<OrderDetail> orderDetails ;
public List<OrderDetail> getOrderDetails() {
return orderDetails;
}
public void setOrderDetails(List<OrderDetail> orderDetails) {
this.orderDetails = orderDetails;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public void setOrderNo(String orderNo)
{
this.orderNo = orderNo;
}
public String getOrderNo()
{
return orderNo;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
public String getOrderNum()
{
return orderNum;
}
public void setUserId(String userId)
{
this.userId = userId;
}
public String getUserId()
{
return userId;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setUserPhone(String userPhone)
{
this.userPhone = userPhone;
}
public String getUserPhone()
{
return userPhone;
}
public void setPayTime(Date payTime)
{
this.payTime = payTime;
}
public Date getPayTime()
{
return payTime;
}
public void setFinishTime(Date finishTime)
{
this.finishTime = finishTime;
}
public Date getFinishTime()
{
return finishTime;
}
public void setAmount(BigDecimal amount)
{
this.amount = amount;
}
public BigDecimal getAmount()
{
return amount;
}
public void setGoodsNum(String goodsNum)
{
this.goodsNum = goodsNum;
}
public String getGoodsNum()
{
return goodsNum;
}
public void setPickCode(String pickCode)
{
this.pickCode = pickCode;
}
public String getPickCode()
{
return pickCode;
}
public void setShopId(String shopId)
{
this.shopId = shopId;
}
public String getShopId()
{
return shopId;
}
public void setMachineId(String machineId)
{
this.machineId = machineId;
}
public String getMachineId()
{
return machineId;
}
public void setSource(Integer source)
{
this.source = source;
}
public Integer getSource()
{
return source;
}
public void setState(String state)
{
this.state = state;
}
public String getState()
{
return state;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
@Override @Override
public String toString() { public String toString() {
......
package com.soss.system.domain; package com.soss.system.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.soss.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.soss.common.annotation.Excel;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* 订单详情对象 order_detail * 订单详情对象 order_detail
* *
* @author zxq * @author zxq
* @date 2022-04-28 * @date 2022-04-28
*/ */
public class OrderDetail implements Serializable @Data
{ public class OrderDetail implements Serializable {
private static final long serialVersionUID = 1L;
/** 主键 */ /**
* 主键
*/
private String id; private String id;
/** 订单ID */ /**
* 订单ID
*/
@Excel(name = "订单ID") @Excel(name = "订单ID")
private long orderId; private long orderId;
/** 商品ID */ /**
* 商品ID
*/
@Excel(name = "商品ID") @Excel(name = "商品ID")
private String goodsId; private Long goodsId;
/** 商品名称 */ /**
* 商品名称
*/
@Excel(name = "商品名称") @Excel(name = "商品名称")
private String goodsName; private String goodsName;
/** 机器ID */ /**
* 机器ID
*/
@Excel(name = "机器ID") @Excel(name = "机器ID")
private String machineId; private String machineId;
/** 数量 */ /**
* 数量
*/
@Excel(name = "数量") @Excel(name = "数量")
private String num; private String num;
/** 应付金额 */ /**
* 展示金额
*/
private BigDecimal viewAmount;
/**
* 应付金额
*/
@Excel(name = "应付金额") @Excel(name = "应付金额")
private BigDecimal amount; private BigDecimal amountShould;
/** 实付金额 */ /**
* 优惠券优惠金额
*/
@Excel(name = "优惠券优惠金额")
private BigDecimal couponAmount;
/**
* 实付金额
*/
@Excel(name = "实付金额") @Excel(name = "实付金额")
private BigDecimal realAmount; private BigDecimal realAmount;
/** 规格选项详情 */ /**
* 规格选项详情
*/
@Excel(name = "规格选项详情") @Excel(name = "规格选项详情")
private String specRuleDetail; private String specRuleDetail;
/** 规格选项id集合 */ /**
* 规格选项id集合
*/
@Excel(name = "规格选项id集合") @Excel(name = "规格选项id集合")
private String specRuleIds; private String specRuleIds;
/** sku ID */ /**
* sku ID
*/
@Excel(name = "sku ID") @Excel(name = "sku ID")
private String skuId; private Long skuId;
/** 商品分类 */ /**
* 商品分类
*/
@Excel(name = "商品分类") @Excel(name = "商品分类")
private String goodsCategory; private String goodsCategory;
public Goods getGoods() {
return goods;
}
public void setGoods(Goods goods) {
this.goods = goods;
}
private Goods goods; private Goods goods;
/** 创建时间 */ /**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd ") @JsonFormat(pattern = "yyyy-MM-dd ")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt; private Date createdAt;
...@@ -85,133 +115,6 @@ public class OrderDetail implements Serializable ...@@ -85,133 +115,6 @@ public class OrderDetail implements Serializable
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt; private Date updatedAt;
public void setId(String id)
{
this.id = id;
}
public String getId()
{
return id;
}
public void setOrderId(long orderId)
{
this.orderId = orderId;
}
public long getOrderId()
{
return orderId;
}
public void setGoodsId(String goodsId)
{
this.goodsId = goodsId;
}
public String getGoodsId()
{
return goodsId;
}
public void setGoodsName(String goodsName)
{
this.goodsName = goodsName;
}
public String getGoodsName()
{
return goodsName;
}
public void setMachineId(String machineId)
{
this.machineId = machineId;
}
public String getMachineId()
{
return machineId;
}
public void setNum(String num)
{
this.num = num;
}
public String getNum()
{
return num;
}
public void setAmount(BigDecimal amount)
{
this.amount = amount;
}
public BigDecimal getAmount()
{
return amount;
}
public void setRealAmount(BigDecimal realAmount)
{
this.realAmount = realAmount;
}
public BigDecimal getRealAmount()
{
return realAmount;
}
public void setSpecRuleDetail(String specRuleDetail)
{
this.specRuleDetail = specRuleDetail;
}
public String getSpecRuleDetail()
{
return specRuleDetail;
}
public void setSpecRuleIds(String specRuleIds)
{
this.specRuleIds = specRuleIds;
}
public String getSpecRuleIds()
{
return specRuleIds;
}
public void setSkuId(String skuId)
{
this.skuId = skuId;
}
public String getSkuId()
{
return skuId;
}
public void setGoodsCategory(String goodsCategory)
{
this.goodsCategory = goodsCategory;
}
public String getGoodsCategory()
{
return goodsCategory;
}
public void setCreatedAt(Date createdAt)
{
this.createdAt = createdAt;
}
public Date getCreatedAt()
{
return createdAt;
}
public void setUpdatedAt(Date updatedAt)
{
this.updatedAt = updatedAt;
}
public Date getUpdatedAt()
{
return updatedAt;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
...@@ -221,7 +124,9 @@ public class OrderDetail implements Serializable ...@@ -221,7 +124,9 @@ public class OrderDetail implements Serializable
.append("goodsName", getGoodsName()) .append("goodsName", getGoodsName())
.append("machineId", getMachineId()) .append("machineId", getMachineId())
.append("num", getNum()) .append("num", getNum())
.append("amount", getAmount()) .append("viewAmount", getViewAmount())
.append("amountShould", getAmountShould())
.append("couponAmount", getCouponAmount())
.append("realAmount", getRealAmount()) .append("realAmount", getRealAmount())
.append("specRuleDetail", getSpecRuleDetail()) .append("specRuleDetail", getSpecRuleDetail())
.append("specRuleIds", getSpecRuleIds()) .append("specRuleIds", getSpecRuleIds())
......
...@@ -8,7 +8,6 @@ import lombok.Data; ...@@ -8,7 +8,6 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
@Data @Data
@ApiModel("优惠券请求类") @ApiModel("优惠券请求类")
...@@ -64,8 +63,8 @@ public class CouponPo { ...@@ -64,8 +63,8 @@ public class CouponPo {
@ApiModelProperty("订单限制 false 整单 true 单杯") @ApiModelProperty("订单限制 false 整单 true 单杯")
private Boolean orderLimit; private Boolean orderLimit;
@ApiModelProperty("周几限制 1,2,3") @ApiModelProperty("周几限制 0表示不限 1-7表示周日到周六")
private List<Integer> weekLimit; private Integer[] weekLimit;
@ApiModelProperty("用户可领取次数之次数限制0无限制,即每N天M次对应的次数") @ApiModelProperty("用户可领取次数之次数限制0无限制,即每N天M次对应的次数")
private Integer userLimit; private Integer userLimit;
...@@ -93,16 +92,11 @@ public class CouponPo { ...@@ -93,16 +92,11 @@ public class CouponPo {
if (shopIds != null && shopIds.length > 0) { if (shopIds != null && shopIds.length > 0) {
limitDim += 1; limitDim += 1;
} }
if (limitDim == 0) {
throw new ServiceException("适用范围之地区/门店还未传递");
}
if (limitDim > 1) { if (limitDim > 1) {
throw new ServiceException("适用范围之地区/门店不能跨级"); throw new ServiceException("适用范围之地区/门店不能跨级");
} }
} }
public boolean isAllCategory() {
return categoryIds != null && categoryIds.length == 1 && categoryIds[0].equals("0");
}
public boolean isAllProvs() {
return province != null && province.length == 1 && province[0].equals("0");
}
} }
package com.soss.system.domain.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("下单时的优惠券请求类")
public class OrderCouponPo {
@ApiModelProperty("店铺ID")
private Long shopId;
@ApiModelProperty("商品skuID")
private List<Long> skuIds;
}
...@@ -5,6 +5,9 @@ import io.swagger.annotations.ApiModel; ...@@ -5,6 +5,9 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.util.Map;
@ApiModel @ApiModel
@Data @Data
public class CouponVo extends CouponPo { public class CouponVo extends CouponPo {
...@@ -36,23 +39,23 @@ public class CouponVo extends CouponPo { ...@@ -36,23 +39,23 @@ public class CouponVo extends CouponPo {
@ApiModelProperty("优惠券类别名") @ApiModelProperty("优惠券类别名")
private String categoryName; private String categoryName;
@ApiModelProperty("可用商品类别描述") @ApiModelProperty("可用商品范围描述")
private String categoryDesc; private String goodLimitDesc;
@ApiModelProperty("可用商品描述") @ApiModelProperty("可用区域/门店描述")
private String goodsDesc; private String areaLimitDesc;
@ApiModelProperty("可用省份描述") @ApiModelProperty("每周几可用描述")
private String provinceDesc; private String weekLimitDesc;
@ApiModelProperty("可用城市描述") @ApiModelProperty(value = "不可用原因,小程序端展示优惠券列表用")
private String cityDesc; private String notFitableDesc;
@ApiModelProperty("可用区域描述") @ApiModelProperty("优惠金额")
private String areaDesc; private BigDecimal couponAmount;
@ApiModelProperty("可用店铺描述") @ApiModelProperty("每个商品优惠金额字典:skuId为key,减免金额为value")
private String shopDesc; private Map<Long, BigDecimal> couponAmountMap;
@ApiModelProperty(value = "可用商品类别列表字符串,全品类传 [0]", hidden = true) @ApiModelProperty(value = "可用商品类别列表字符串,全品类传 [0]", hidden = true)
private String categoryIdStr; private String categoryIdStr;
...@@ -71,4 +74,7 @@ public class CouponVo extends CouponPo { ...@@ -71,4 +74,7 @@ public class CouponVo extends CouponPo {
@ApiModelProperty(value = "可用店铺ID列表字符串", hidden = true) @ApiModelProperty(value = "可用店铺ID列表字符串", hidden = true)
private String shopIdStr; private String shopIdStr;
@ApiModelProperty(value = "每周几可用字符串", hidden = true)
private String weekLimitStr;
} }
...@@ -64,7 +64,7 @@ public interface CouponUserMapper { ...@@ -64,7 +64,7 @@ public interface CouponUserMapper {
* @param nowTime * @param nowTime
* @return * @return
*/ */
List<CouponVo> listCustAvailableCoupon(@Param("custId") String custId, @Param("nowTime") LocalDateTime nowTime); List<CouponVo> listCustAvailableCoupon(@Param("custId") String custId, @Param("couponId") Integer couponId, @Param("nowTime") LocalDateTime nowTime);
/** /**
* 查询用户领取优惠券列表 * 查询用户领取优惠券列表
......
...@@ -19,7 +19,7 @@ public interface GoodsMapper ...@@ -19,7 +19,7 @@ public interface GoodsMapper
* @param id 商品主键 * @param id 商品主键
* @return 商品 * @return 商品
*/ */
public Goods selectGoodsById(String id); public Goods selectGoodsById(Long id);
/** /**
* 查询商品列表 * 查询商品列表
......
package com.soss.system.mapper; package com.soss.system.mapper;
import java.util.List;
import com.soss.system.domain.GoodsSku; import com.soss.system.domain.GoodsSku;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 由规格选项组合生成商品skuMapper接口 * 由规格选项组合生成商品skuMapper接口
* *
...@@ -22,15 +23,23 @@ public interface GoodsSkuMapper ...@@ -22,15 +23,23 @@ public interface GoodsSkuMapper
/** /**
* 查询由规格选项组合生成商品sku列表 * 查询由规格选项组合生成商品sku列表
* *
* @param goodsSku 由规格选项组合生成商品sku * @param goodsSku 由规格选项组合生成商品sku
* @return 由规格选项组合生成商品sku集合 * @return 由规格选项组合生成商品sku集合
*/ */
public List<GoodsSku> selectGoodsSkuList(GoodsSku goodsSku); public List<GoodsSku> selectGoodsSkuList(GoodsSku goodsSku);
/** /**
* 下单时查询sku列表信息
*
* @param ids
* @return
*/
List<GoodsSku> selectSkuListForOrder(@Param("ids") List<Long> ids);
/**
* 新增由规格选项组合生成商品sku * 新增由规格选项组合生成商品sku
* *
* @param goodsSku 由规格选项组合生成商品sku * @param goodsSku 由规格选项组合生成商品sku
* @return 结果 * @return 结果
*/ */
......
package com.soss.system.mapper; package com.soss.system.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.vo.OrderQuery; import com.soss.system.domain.vo.OrderQuery;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/** /**
* 订单Mapper接口 * 订单Mapper接口
* *
* @author zxq * @author zxq
* @date 2022-04-28 * @date 2022-04-28
*/ */
public interface OrderMapper public interface OrderMapper {
{
/** /**
* 查询订单 * 查询订单
* *
* @param id 订单主键 * @param id 订单主键
* @return 订单 * @return 订单
*/ */
...@@ -76,13 +77,21 @@ public interface OrderMapper ...@@ -76,13 +77,21 @@ public interface OrderMapper
Order selectHomeByUserId(@Param("userId") String openId, @Param("status") List<String> status, @Param("shopId") String shopId); Order selectHomeByUserId(@Param("userId") String openId, @Param("status") List<String> status, @Param("shopId") String shopId);
void updateTimeOut(@Param("status") String productionCompleted,@Param("timeout") String timeout); void updateTimeOut(@Param("status") String productionCompleted, @Param("timeout") String timeout);
List<Order> selectOrderByUserId(@Param("userId") String openId,@Param("status") List<String> status); List<Order> selectOrderByUserId(@Param("userId") String openId, @Param("status") List<String> status);
void updateCancel(@Param("status") String unpaid, @Param("timeout") int i); void updateCancel(@Param("status") String unpaid, @Param("timeout") int i);
List<Order> selectOrderByTime(@Param("status")String unpaid, @Param("timeout")int i); List<Order> selectOrderByTime(@Param("status") String unpaid, @Param("timeout") int i);
List<Order> selectBeforeOrder(@Param("status") List<String> status, @Param("orderId") Long orderId);
List<Order> selectBeforeOrder(@Param("status")List<String> status, @Param("orderId")Long orderId); /**
* 查询用户订单简单统计数据
*
* @param custId
* @return 返回用户下单数,下单金额
*/
Map<String, Object> getCustOrderSimpleStat(@Param("custId") String custId);
} }
package com.soss.system.service; package com.soss.system.service;
import com.soss.system.domain.CouponUser; import com.soss.system.domain.CouponUser;
import com.soss.system.domain.Order;
import com.soss.system.domain.vo.CouponUserVo; import com.soss.system.domain.vo.CouponUserVo;
import com.soss.system.domain.vo.CouponVo; import com.soss.system.domain.vo.CouponVo;
...@@ -22,7 +23,9 @@ public interface ICouponUserService { ...@@ -22,7 +23,9 @@ public interface ICouponUserService {
int getCustAvailableCouponCnt(String custId); int getCustAvailableCouponCnt(String custId);
List<CouponVo> listCustAvailableCoupon(String custId); List<CouponVo> listCustAvailableCoupon(String custId, Integer couponId);
List<CouponUserVo> selectCouponUserList(CouponUser couponUser); List<CouponUserVo> selectCouponUserList(CouponUser couponUser);
void resovleCouponFitable(List<CouponVo> couponVos, Order order);
} }
package com.soss.system.service; package com.soss.system.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.soss.system.domain.Customer; import com.soss.system.domain.Customer;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo; import com.soss.system.domain.vo.customer.CustomerQueryVo;
...@@ -64,4 +66,6 @@ public interface ICustomerService ...@@ -64,4 +66,6 @@ public interface ICustomerService
public int deleteCustomerById(Long id); public int deleteCustomerById(Long id);
Integer allow(String openId, String allow); Integer allow(String openId, String allow);
Map<String, Object> getCustSimpleOrderStat(String custId);
} }
...@@ -2,6 +2,7 @@ package com.soss.system.service; ...@@ -2,6 +2,7 @@ package com.soss.system.service;
import java.util.List; import java.util.List;
import com.soss.system.domain.Goods; import com.soss.system.domain.Goods;
import com.soss.system.domain.GoodsSku;
/** /**
* 商品Service接口 * 商品Service接口
...@@ -17,7 +18,7 @@ public interface IGoodsService ...@@ -17,7 +18,7 @@ public interface IGoodsService
* @param id 商品主键 * @param id 商品主键
* @return 商品 * @return 商品
*/ */
public Goods selectGoodsById(String id); public Goods selectGoodsById(Long id);
/** /**
* 查询商品列表 * 查询商品列表
...@@ -64,4 +65,6 @@ public interface IGoodsService ...@@ -64,4 +65,6 @@ public interface IGoodsService
String offShop(Long goodsId, boolean boo); String offShop(Long goodsId, boolean boo);
String deleteGoodsById(Long goodsId, boolean boo); String deleteGoodsById(Long goodsId, boolean boo);
List<GoodsSku> getGoodsSkus(long goodsId);
} }
...@@ -41,6 +41,8 @@ public interface IOrderService ...@@ -41,6 +41,8 @@ public interface IOrderService
*/ */
public AjaxResult insertOrder(LoginUser request, Order order); public AjaxResult insertOrder(LoginUser request, Order order);
void checkBusinessTime(String shopId);
/** /**
* 修改订单 * 修改订单
* *
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.soss.system.constants.SystemConstant;
import com.soss.system.domain.CouponRule; import com.soss.system.domain.CouponRule;
import com.soss.system.domain.Goods; import com.soss.system.domain.Goods;
import com.soss.system.domain.GoodsCategory; import com.soss.system.domain.GoodsCategory;
...@@ -11,7 +12,7 @@ import com.soss.system.mapper.GoodsMapper; ...@@ -11,7 +12,7 @@ import com.soss.system.mapper.GoodsMapper;
import com.soss.system.mapper.ShopMapper; import com.soss.system.mapper.ShopMapper;
import com.soss.system.service.ICouponRuleService; import com.soss.system.service.ICouponRuleService;
import com.soss.system.utils.AreaUtil; import com.soss.system.utils.AreaUtil;
import com.soss.system.utils.CollectionUtil; import com.soss.system.utils.ArrayUtil;
import io.jsonwebtoken.lang.Assert; import io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -68,16 +69,27 @@ public class CouponRuleServiceImpl implements ICouponRuleService { ...@@ -68,16 +69,27 @@ public class CouponRuleServiceImpl implements ICouponRuleService {
} }
transCategoryIds(couponVos); transCategoryIds(couponVos);
translateArea(couponVos); translateArea(couponVos);
translateWeekLimit(couponVos);
}
private void translateWeekLimit(List<CouponVo> couponVos) {
for (CouponVo couponVo : couponVos) {
if (!ArrayUtil.isAllAvailable(couponVo.getWeekLimit())) {
String weekLimitDesc = Arrays.stream(couponVo.getWeekLimit())
.map(week -> "每" + SystemConstant.WEEK_DESC[week - 1]).collect(Collectors.joining(","));
couponVo.setWeekLimitDesc(weekLimitDesc);
}
}
} }
private void transCategoryIds(List<CouponVo> couponVos) { private void transCategoryIds(List<CouponVo> couponVos) {
List<String> categoryIds = new ArrayList<>(16); List<String> categoryIds = new ArrayList<>(16);
List<Long> goodsIds = new ArrayList<>(16); List<Long> goodsIds = new ArrayList<>(16);
for (CouponVo couponVo : couponVos) { for (CouponVo couponVo : couponVos) {
if (!couponVo.isAllCategory()) { if (!ArrayUtil.isAllAvailable(couponVo.getCategoryIds())) {
CollectionUtil.listAddArray(categoryIds, couponVo.getCategoryIds()); ArrayUtil.listAddArray(categoryIds, couponVo.getCategoryIds());
} }
CollectionUtil.listAddArray(goodsIds, couponVo.getGoodsIds()); ArrayUtil.listAddArray(goodsIds, couponVo.getGoodsIds());
} }
Map<String, String> categoryMap; Map<String, String> categoryMap;
...@@ -97,18 +109,18 @@ public class CouponRuleServiceImpl implements ICouponRuleService { ...@@ -97,18 +109,18 @@ public class CouponRuleServiceImpl implements ICouponRuleService {
} }
for (CouponVo couponVo : couponVos) { for (CouponVo couponVo : couponVos) {
if (couponVo.isAllCategory()) { if (ArrayUtil.isAllAvailable(couponVo.getCategoryIds())) {
couponVo.setCategoryDesc("全品类"); couponVo.setGoodLimitDesc("全品类");
continue; continue;
} else if (CollectionUtil.hasContents(couponVo.getCategoryIds())) { } else if (ArrayUtil.hasContents(couponVo.getCategoryIds())) {
String categoryDec = Arrays.stream(couponVo.getCategoryIds()).map(categoryMap::get).collect(Collectors.joining(",")); String categoryDec = Arrays.stream(couponVo.getCategoryIds()).map(categoryMap::get).collect(Collectors.joining(","));
couponVo.setCategoryDesc(categoryDec); couponVo.setGoodLimitDesc(categoryDec);
continue; continue;
} }
if (CollectionUtil.hasContents(couponVo.getGoodsIds())) { if (ArrayUtil.hasContents(couponVo.getGoodsIds())) {
String goodsDesc = Arrays.stream(couponVo.getGoodsIds()).map(goodsMap::get).collect(Collectors.joining(",")); String goodsDesc = Arrays.stream(couponVo.getGoodsIds()).map(goodsMap::get).collect(Collectors.joining(","));
couponVo.setGoodsDesc(goodsDesc); couponVo.setGoodLimitDesc(goodsDesc);
} }
} }
} }
...@@ -119,12 +131,12 @@ public class CouponRuleServiceImpl implements ICouponRuleService { ...@@ -119,12 +131,12 @@ public class CouponRuleServiceImpl implements ICouponRuleService {
List<String> area = new ArrayList<>(16); List<String> area = new ArrayList<>(16);
List<Long> shopIds = new ArrayList<>(16); List<Long> shopIds = new ArrayList<>(16);
for (CouponVo couponVo : couponVos) { for (CouponVo couponVo : couponVos) {
if (!couponVo.isAllProvs()) { if (!ArrayUtil.isAllAvailable(couponVo.getProvince())) {
CollectionUtil.listAddArray(province, couponVo.getProvince()); ArrayUtil.listAddArray(province, couponVo.getProvince());
} }
CollectionUtil.listAddArray(city, couponVo.getCity()); ArrayUtil.listAddArray(city, couponVo.getCity());
CollectionUtil.listAddArray(area, couponVo.getArea()); ArrayUtil.listAddArray(area, couponVo.getArea());
CollectionUtil.listAddArray(shopIds, couponVo.getShopIds()); ArrayUtil.listAddArray(shopIds, couponVo.getShopIds());
} }
Map<Long, Shop> shopMapInit; Map<Long, Shop> shopMapInit;
...@@ -137,27 +149,28 @@ public class CouponRuleServiceImpl implements ICouponRuleService { ...@@ -137,27 +149,28 @@ public class CouponRuleServiceImpl implements ICouponRuleService {
Map<Long, Shop> shopMap = shopMapInit; Map<Long, Shop> shopMap = shopMapInit;
for (CouponVo couponVo : couponVos) { for (CouponVo couponVo : couponVos) {
if (couponVo.isAllProvs()) { if (ArrayUtil.isAllAvailable(couponVo.getProvince())) {
couponVo.setProvinceDesc("全国通用"); couponVo.setAreaLimitDesc("全国通用");
continue;
} else if (ArrayUtil.hasContents(couponVo.getProvince())) {
String provDesc = Arrays.stream(couponVo.getProvince()).map(areaUtil::getProvNameByCode).collect(Collectors.joining(","));
couponVo.setAreaLimitDesc(provDesc);
continue; continue;
} else if (CollectionUtil.hasContents(couponVo.getProvince())) {
String provDesc = Arrays.stream(couponVo.getProvince()).map(areaUtil::getAreaNameByCode).collect(Collectors.joining(","));
couponVo.setProvinceDesc(provDesc);
} }
if (CollectionUtil.hasContents(couponVo.getCity())) { if (ArrayUtil.hasContents(couponVo.getCity())) {
String cityDesc = Arrays.stream(couponVo.getCity()).map(areaUtil::getAreaNameByCode).collect(Collectors.joining(",")); String cityDesc = Arrays.stream(couponVo.getCity()).map(areaUtil::getCityOrAreaNameByCode).collect(Collectors.joining(","));
couponVo.setCityDesc(cityDesc); couponVo.setAreaLimitDesc(cityDesc);
continue; continue;
} }
if (CollectionUtil.hasContents(couponVo.getArea())) { if (ArrayUtil.hasContents(couponVo.getArea())) {
String areaDesc = Arrays.stream(couponVo.getArea()).map(areaUtil::getAreaNameByCode).collect(Collectors.joining(",")); String areaDesc = Arrays.stream(couponVo.getArea()).map(areaUtil::getCityOrAreaNameByCode).collect(Collectors.joining(","));
couponVo.setAreaDesc(areaDesc); couponVo.setAreaLimitDesc(areaDesc);
continue; continue;
} }
if (!CollectionUtil.hasContents(couponVo.getShopIds())) { if (!ArrayUtil.hasContents(couponVo.getShopIds())) {
continue; continue;
} }
...@@ -166,9 +179,9 @@ public class CouponRuleServiceImpl implements ICouponRuleService { ...@@ -166,9 +179,9 @@ public class CouponRuleServiceImpl implements ICouponRuleService {
if (shop == null) { if (shop == null) {
return null; return null;
} }
return areaUtil.getAreaNameByCode(shop.getZone()) + shop.getName(); return areaUtil.getCityOrAreaNameByCode(shop.getZone()) + shop.getName();
}).filter(Objects::nonNull).collect(Collectors.joining(",")); }).filter(Objects::nonNull).collect(Collectors.joining(","));
couponVo.setShopDesc(shopDesc); couponVo.setAreaLimitDesc(shopDesc);
} }
} }
} }
...@@ -13,6 +13,7 @@ import com.soss.system.mapper.CouponMapper; ...@@ -13,6 +13,7 @@ import com.soss.system.mapper.CouponMapper;
import com.soss.system.mapper.CouponRuleMapper; import com.soss.system.mapper.CouponRuleMapper;
import com.soss.system.mapper.CouponUserMapper; import com.soss.system.mapper.CouponUserMapper;
import com.soss.system.service.ICouponService; import com.soss.system.service.ICouponService;
import com.soss.system.utils.ArrayUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -120,6 +121,7 @@ public class CouponServiceImpl implements ICouponService { ...@@ -120,6 +121,7 @@ public class CouponServiceImpl implements ICouponService {
} else if (CouponCategoryType.DISCOUNT.getType().equals(couponCategory.getType())) { } else if (CouponCategoryType.DISCOUNT.getType().equals(couponCategory.getType())) {
Assert.notNull(couponPo.getPriceDiscount(), "打折数还未设置"); Assert.notNull(couponPo.getPriceDiscount(), "打折数还未设置");
Assert.notNull(couponPo.getOrderLimit(), "订单限制还未设置"); Assert.notNull(couponPo.getOrderLimit(), "订单限制还未设置");
couponPo.setPriceLimit(BigDecimal.ZERO);
ruleName = couponPo.getOrderLimit() + "折"; ruleName = couponPo.getOrderLimit() + "折";
ruleDesc = couponPo.getOrderLimit() ? "单杯" : "整单"; ruleDesc = couponPo.getOrderLimit() ? "单杯" : "整单";
} else { } else {
...@@ -143,7 +145,14 @@ public class CouponServiceImpl implements ICouponService { ...@@ -143,7 +145,14 @@ public class CouponServiceImpl implements ICouponService {
} }
Assert.isTrue((couponPo.getCategoryIds() != null && couponPo.getCategoryIds().length > 0) Assert.isTrue((couponPo.getCategoryIds() != null && couponPo.getCategoryIds().length > 0)
|| (couponPo.getGoodsIds() != null && couponPo.getGoodsIds().length > 0), "商品范围还未设置"); || (couponPo.getGoodsIds() != null && couponPo.getGoodsIds().length > 0), "商品范围还未设置");
if (!ArrayUtil.isEmpty(couponPo.getCategoryIds()) && !ArrayUtil.isEmpty(couponPo.getGoodsIds())) {
throw new ServiceException("品类范围和商品范围不能重叠选择");
}
couponPo.couponUseLimitCheck(); couponPo.couponUseLimitCheck();
Assert.notEmpty(couponPo.getWeekLimit(), "每周几的限制还未传递");
Integer maxWeekVal = Arrays.stream(couponPo.getWeekLimit()).max(Integer::compareTo).get();
Integer minWeekVal = Arrays.stream(couponPo.getWeekLimit()).min(Integer::compareTo).get();
Assert.isTrue(minWeekVal >= 0 && maxWeekVal <= 7, "每周几的值超出范围,应在[0,7]之内");
Assert.notNull(couponPo.getSendMsg(), "是否短信通知还未设置"); Assert.notNull(couponPo.getSendMsg(), "是否短信通知还未设置");
Assert.isTrue(!couponPo.getSendMsg() || couponPo.getMsgId() != null, "短信模板还未选择"); Assert.isTrue(!couponPo.getSendMsg() || couponPo.getMsgId() != null, "短信模板还未选择");
...@@ -183,6 +192,7 @@ public class CouponServiceImpl implements ICouponService { ...@@ -183,6 +192,7 @@ public class CouponServiceImpl implements ICouponService {
} else { } else {
couponRule.setShopIds(Arrays.stream(couponPo.getShopIds()).map(String::valueOf).collect(Collectors.joining(","))); couponRule.setShopIds(Arrays.stream(couponPo.getShopIds()).map(String::valueOf).collect(Collectors.joining(",")));
} }
couponRule.setWeekLimit(Arrays.stream(couponPo.getWeekLimit()).map(String::valueOf).collect(Collectors.joining(",")));
if (saveFlag) { if (saveFlag) {
couponRule.setCreatedAt(now); couponRule.setCreatedAt(now);
} }
......
package com.soss.system.service.impl; package com.soss.system.service.impl;
import com.soss.common.enums.CouponCategoryType;
import com.soss.common.enums.CouponState; import com.soss.common.enums.CouponState;
import com.soss.common.enums.CouponUserType; import com.soss.common.enums.CouponUserType;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
import com.soss.common.utils.DateUtils; import com.soss.common.utils.DateUtils;
import com.soss.system.domain.Coupon; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.CouponRule; import com.soss.system.domain.*;
import com.soss.system.domain.CouponUser;
import com.soss.system.domain.Customer;
import com.soss.system.domain.vo.CouponUserVo; import com.soss.system.domain.vo.CouponUserVo;
import com.soss.system.domain.vo.CouponVo; import com.soss.system.domain.vo.CouponVo;
import com.soss.system.mapper.CouponMapper; import com.soss.system.mapper.*;
import com.soss.system.mapper.CouponRuleMapper;
import com.soss.system.mapper.CouponUserMapper;
import com.soss.system.mapper.CustomerMapper;
import com.soss.system.service.ICouponUserService; import com.soss.system.service.ICouponUserService;
import com.soss.system.utils.ArrayUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.*;
import java.util.Objects; import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -33,6 +33,7 @@ import java.util.Objects; ...@@ -33,6 +33,7 @@ import java.util.Objects;
* @since 2022-07-21 * @since 2022-07-21
*/ */
@Service @Service
@Slf4j
public class CouponUserServiceImpl implements ICouponUserService { public class CouponUserServiceImpl implements ICouponUserService {
@Autowired @Autowired
private CouponUserMapper couponUserMapper; private CouponUserMapper couponUserMapper;
...@@ -42,6 +43,12 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -42,6 +43,12 @@ public class CouponUserServiceImpl implements ICouponUserService {
private CouponRuleMapper couponRuleMapper; private CouponRuleMapper couponRuleMapper;
@Autowired @Autowired
private CustomerMapper customerMapper; private CustomerMapper customerMapper;
@Autowired
private ShopMapper shopMapper;
@Autowired
private GoodsMapper goodsMapper;
@Autowired
private GoodsSkuMapper goodsSkuMapper;
@Override @Override
public void giveUserCoupon(String custId, Integer couponId) { public void giveUserCoupon(String custId, Integer couponId) {
...@@ -119,11 +126,22 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -119,11 +126,22 @@ public class CouponUserServiceImpl implements ICouponUserService {
* 查询用户可用优惠券列表 * 查询用户可用优惠券列表
* *
* @param custId * @param custId
* @param couponId
* @return * @return
*/ */
@Override @Override
public List<CouponVo> listCustAvailableCoupon(String custId) { public List<CouponVo> listCustAvailableCoupon(String custId, Integer couponId) {
return couponUserMapper.listCustAvailableCoupon(custId, LocalDateTime.now()); List<CouponVo> couponVos = couponUserMapper.listCustAvailableCoupon(custId, couponId, LocalDateTime.now());
couponVos.forEach(couponVo -> {
couponVo.setCategoryIds(ArrayUtil.transStrToCodeList(couponVo.getCategoryIdStr()));
couponVo.setGoodsIds(ArrayUtil.transStrToLongList(couponVo.getGoodsIdStr()));
couponVo.setProvince(ArrayUtil.transStrToCodeList(couponVo.getProvinceStr()));
couponVo.setCity(ArrayUtil.transStrToCodeList(couponVo.getCityStr()));
couponVo.setArea(ArrayUtil.transStrToCodeList(couponVo.getAreaStr()));
couponVo.setShopIds(ArrayUtil.transStrToLongList(couponVo.getShopIdStr()));
couponVo.setWeekLimit(ArrayUtil.transStrToIntList(couponVo.getWeekLimitStr()));
});
return couponVos;
} }
/** /**
...@@ -136,4 +154,130 @@ public class CouponUserServiceImpl implements ICouponUserService { ...@@ -136,4 +154,130 @@ public class CouponUserServiceImpl implements ICouponUserService {
public List<CouponUserVo> selectCouponUserList(CouponUser couponUser) { public List<CouponUserVo> selectCouponUserList(CouponUser couponUser) {
return couponUserMapper.selectCouponUserList(couponUser); return couponUserMapper.selectCouponUserList(couponUser);
} }
@Override
public void resovleCouponFitable(List<CouponVo> couponVos, Order order) {
/** 可用门店和时段的校验 */
this.checkShopAndWeeklyFitable(couponVos, order.getShopId());
/** 可用饮品范围的判断 */
checkGoodsFitable(couponVos, order.getOrderDetails());
}
private void checkGoodsFitable(List<CouponVo> couponVos, List<OrderDetail> orderDetails) {
Assert.notEmpty(orderDetails, "商品明细还未传递");
List<Long> skuIds = orderDetails.stream().map(OrderDetail::getSkuId).collect(Collectors.toList());
Assert.notEmpty(skuIds, "skuId还未传递");
List<GoodsSku> goodsSkus = goodsSkuMapper.selectSkuListForOrder(skuIds);
log.info("sku id size is {} and query size is {}", skuIds.size(), goodsSkus.size());
Assert.isTrue(goodsSkus.size() == skuIds.size(), "未查询到匹配的sku记录");
List<Long> goodsIds = goodsSkus.stream().map(GoodsSku::getGoodsId).collect(Collectors.toList());
List<Goods> goods = goodsMapper.selectGoodsByIds(goodsIds);
Assert.notEmpty(goods, "未查询到匹配的商品信息[id=" + goodsIds + "]");
// sku的ID和价格字典
Map<Long, BigDecimal> skuIdPriceMap = goodsSkus.stream().collect(Collectors.toMap(GoodsSku::getId, GoodsSku::getDiscount));
// 订单总额
BigDecimal orderTotalAmount = orderDetails.stream().map(orderDetail ->
new BigDecimal(orderDetail.getNum()).multiply(skuIdPriceMap.get(orderDetail.getSkuId()))).reduce(BigDecimal.ZERO, BigDecimal::add);
couponVos.stream().filter(couponVo -> StringUtils.isEmpty(couponVo.getNotFitableDesc())).forEach(couponVo -> {
/** 可用饮品范围的判断 */
List<Long> fitCouponGoodsIdList = goods.stream().filter(good ->
(ArrayUtil.isAllAvailable(couponVo.getCategoryIds()) || ArrayUtil.contains(couponVo.getCategoryIds(), good.getCategory()))
&& (ArrayUtil.isEmpty(couponVo.getGoodsIds()) || ArrayUtil.contains(couponVo.getGoodsIds(), good.getId())))
.map(Goods::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(fitCouponGoodsIdList)) {
if (!ArrayUtil.isAllAvailable(couponVo.getCategoryIds())) {
couponVo.setNotFitableDesc("限定品类使用");
} else {
couponVo.setNotFitableDesc("限定商品使用");
}
return;
}
/** 券价值的判断 */
if (couponVo.getType().equals(CouponCategoryType.DEDUCTION.getType())) { // 抵扣
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(orderTotalAmount) > 0) {
couponVo.setNotFitableDesc("未达到满减要求");
}
couponVo.setCouponAmount(couponVo.getPriceDiscount().min(orderTotalAmount));
} else {
List<OrderDetail> fitOrderDetails = orderDetails.stream().filter(orderDetail -> fitCouponGoodsIdList.contains(orderDetail.getGoodsId())).collect(Collectors.toList());
Map<Long, BigDecimal> fitSkuMap = fitOrderDetails.stream().collect(Collectors.toMap(OrderDetail::getSkuId, orderDetail ->
new BigDecimal(orderDetail.getNum()).multiply(skuIdPriceMap.get(orderDetail.getSkuId()))));
BigDecimal fitGoodsAmount = fitSkuMap.values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
if (couponVo.getPriceLimit() != null && couponVo.getPriceLimit().compareTo(BigDecimal.ZERO) != 0 && couponVo.getPriceLimit().compareTo(fitGoodsAmount) > 0) {
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
couponVo.setNotFitableDesc("未达到满减要求");
} else { // 免单
couponVo.setNotFitableDesc("未达到免单要求");
}
}
this.wrapperCouponAmount(couponVo, fitOrderDetails, fitSkuMap, fitGoodsAmount);
}
});
}
private void wrapperCouponAmount(CouponVo couponVo, List<OrderDetail> fitOrderDetails, Map<Long, BigDecimal> fitSkuMap, BigDecimal fitGoodsAmount) {
Map<Long, BigDecimal> couponAmountMap = new HashMap<>();
if (couponVo.getOrderLimit() != null && couponVo.getOrderLimit()) { // 单杯
BigDecimal discountAmount = fitSkuMap.values().stream().max(BigDecimal::compareTo).get();
Long couponSkuId = fitOrderDetails.stream().filter(orderDetail -> fitSkuMap.get(orderDetail.getSkuId()).compareTo(BigDecimal.ZERO) == 0).findFirst().get().getSkuId();
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
couponVo.setCouponAmount(this.getDiscountAmount(discountAmount, couponVo.getPriceDiscount()));
} else { // 免单
couponVo.setCouponAmount(discountAmount);
}
couponAmountMap.put(couponSkuId, discountAmount);
} else { // 整单
if (couponVo.getType().equals(CouponCategoryType.DISCOUNT.getType())) { // 折扣
couponVo.setCouponAmount(this.getDiscountAmount(fitGoodsAmount, couponVo.getPriceDiscount()));
fitOrderDetails.forEach(orderDetail -> orderDetail.setCouponAmount(this.getDiscountAmount(fitSkuMap.get(orderDetail.getSkuId()), couponVo.getPriceDiscount())));
// 订单明细优惠总和
BigDecimal detailCouponSum = fitOrderDetails.stream().map(OrderDetail::getCouponAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
// 如果订单明细优惠总额大于订单总优惠金额,则将订单明细最后一条记录的优惠金额去掉差额
if (detailCouponSum.compareTo(couponVo.getCouponAmount()) > 0) {
OrderDetail orderDetail = fitOrderDetails.get(fitOrderDetails.size() - 1);
orderDetail.setCouponAmount(orderDetail.getCouponAmount().add(couponVo.getCouponAmount().subtract(detailCouponSum)));
}
} else { // 免单
couponVo.setCouponAmount(fitGoodsAmount);
}
fitOrderDetails.forEach(orderDetail -> couponAmountMap.put(orderDetail.getSkuId(), orderDetail.getCouponAmount()));
}
couponVo.setCouponAmountMap(couponAmountMap);
}
private void checkShopAndWeeklyFitable(List<CouponVo> couponVos, String shopId) {
Assert.notNull(shopId, "商店id还未传递");
Shop shop = shopMapper.selectShopById(shopId);
Assert.notNull(shop, "未查询到匹配的商店[id=" + shopId + "]");
// 当天周几
int dayOfWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
couponVos.forEach(couponVo -> {
/** 可用门店的判断 */
if (!ArrayUtil.isAllAvailable(couponVo.getProvince()) && !ArrayUtil.contains(couponVo.getProvince(), shop.getProvince())) {
couponVo.setNotFitableDesc("限定区域使用");
return;
}
if (!ArrayUtil.isEmpty(couponVo.getCity()) && !ArrayUtil.contains(couponVo.getCity(), shop.getCity())) {
couponVo.setNotFitableDesc("限定区域使用");
return;
}
if (!ArrayUtil.isEmpty(couponVo.getArea()) && !ArrayUtil.contains(couponVo.getArea(), shop.getZone())) {
couponVo.setNotFitableDesc("限定区域使用");
return;
}
if (!ArrayUtil.isEmpty(couponVo.getShopIds()) && !ArrayUtil.contains(couponVo.getShopIds(), shop.getId())) {
couponVo.setNotFitableDesc("限定门店使用");
return;
}
/** 可用时段的判断 */
if (!ArrayUtil.isAllAvailable(couponVo.getWeekLimit()) && !ArrayUtil.contains(couponVo.getWeekLimit(), dayOfWeek)) {
couponVo.setNotFitableDesc("限定时段使用");
}
});
}
private BigDecimal getDiscountAmount(BigDecimal amount, BigDecimal priceDiscount) {
return amount.multiply(priceDiscount.divide(BigDecimal.TEN, 4, BigDecimal.ROUND_HALF_UP)).setScale(2, BigDecimal.ROUND_HALF_UP).min(amount);
}
} }
package com.soss.system.service.impl; package com.soss.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.soss.common.utils.DateUtils; import com.soss.common.utils.DateUtils;
import com.soss.system.constants.OrderStatusConstant; import com.soss.system.constants.OrderStatusConstant;
import com.soss.system.domain.Customer;
import com.soss.system.domain.Order; import com.soss.system.domain.Order;
import com.soss.system.domain.vo.customer.CustomerQueryVo; import com.soss.system.domain.vo.customer.CustomerQueryVo;
import com.soss.system.domain.vo.customer.CustomerResultVo; import com.soss.system.domain.vo.customer.CustomerResultVo;
import com.soss.system.mapper.CustomerMapper;
import com.soss.system.mapper.OrderMapper; import com.soss.system.mapper.OrderMapper;
import com.soss.system.mapper.ShopMapper; import com.soss.system.mapper.ShopMapper;
import com.soss.system.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.soss.system.mapper.CustomerMapper;
import com.soss.system.domain.Customer; import java.util.Arrays;
import com.soss.system.service.ICustomerService; import java.util.List;
import java.util.Map;
/** /**
* 用户信息Service业务层处理 * 用户信息Service业务层处理
...@@ -135,4 +135,9 @@ public class CustomerServiceImpl implements ICustomerService ...@@ -135,4 +135,9 @@ public class CustomerServiceImpl implements ICustomerService
customer.setAllow("1"); customer.setAllow("1");
return customerMapper.updateCustomer(customer); return customerMapper.updateCustomer(customer);
} }
@Override
public Map<String, Object> getCustSimpleOrderStat(String custId) {
return orderMapper.getCustOrderSimpleStat(custId);
}
} }
package com.soss.system.service.impl; package com.soss.system.service.impl;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
...@@ -11,14 +7,17 @@ import com.soss.common.utils.GenerateCode; ...@@ -11,14 +7,17 @@ import com.soss.common.utils.GenerateCode;
import com.soss.common.utils.StringUtils; import com.soss.common.utils.StringUtils;
import com.soss.system.domain.*; import com.soss.system.domain.*;
import com.soss.system.jiguang.impl.JiGuangPushServiceImpl; import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IGoodsService;
import com.soss.system.mapper.*; import com.soss.system.mapper.*;
import com.soss.system.service.IGoodsService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* 商品Service业务层处理 * 商品Service业务层处理
* *
...@@ -60,7 +59,7 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -60,7 +59,7 @@ public class GoodsServiceImpl implements IGoodsService
* @return 商品 * @return 商品
*/ */
@Override @Override
public Goods selectGoodsById(String id) public Goods selectGoodsById(Long id)
{ {
Goods goods = goodsMapper.selectGoodsById(id); Goods goods = goodsMapper.selectGoodsById(id);
GoodsTag goodsTag = new GoodsTag(); GoodsTag goodsTag = new GoodsTag();
...@@ -225,15 +224,18 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -225,15 +224,18 @@ public class GoodsServiceImpl implements IGoodsService
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateGoods(Goods goods) public int updateGoods(Goods goods) {
{ Goods goodsOri = goodsMapper.selectGoodsById(goods.getId());
int i = goodsMapper.updateGoods(goods); int i = goodsMapper.updateGoods(goods);
if(StringUtils.isNotEmpty(goods.getSpec())){ if (Objects.equals(goodsOri.getSpec(), goods.getSpec())) {
goodsSkuMapper.deleteGoodsSkuByGoodsId(String.valueOf(goods.getId())); return i;
} }
if(goods.getGoodsTagList()!=null &&!goods.getGoodsTagList().isEmpty()){ /*if(StringUtils.isNotEmpty(goods.getSpec())){
goodsSkuMapper.deleteGoodsSkuByGoodsId(String.valueOf(goods.getId()));
}*/
goodsSkuMapper.deleteGoodsSkuByGoodsId(String.valueOf(goods.getId()));
if (goods.getGoodsTagList() != null && !goods.getGoodsTagList().isEmpty()) {
goodsTagMapper.deleteGoodsTagByGoodsId(String.valueOf(goods.getId())); goodsTagMapper.deleteGoodsTagByGoodsId(String.valueOf(goods.getId()));
} }
insertgoodsExt(goods); insertgoodsExt(goods);
return i; return i;
...@@ -357,19 +359,12 @@ public class GoodsServiceImpl implements IGoodsService ...@@ -357,19 +359,12 @@ public class GoodsServiceImpl implements IGoodsService
return "1"; return "1";
} }
@Override
public List<GoodsSku> getGoodsSkus(long goodsId){ public List<GoodsSku> getGoodsSkus(long goodsId){
GoodsSku goodsSku = new GoodsSku(); GoodsSku goodsSku = new GoodsSku();
goodsSku.setGoodsId(goodsId); goodsSku.setGoodsId(goodsId);
goodsSku.setIsDeleted("0"); goodsSku.setIsDeleted("0");
return goodsSkuMapper.selectGoodsSkuList(goodsSku); return goodsSkuMapper.selectGoodsSkuList(goodsSku);
}
public String test() {
Goods goods = goodsMapper.selectGoodsById("21");
insertgoodsExt(goods);
return null;
} }
......
...@@ -191,13 +191,13 @@ public class MachineApiServiceImpl { ...@@ -191,13 +191,13 @@ public class MachineApiServiceImpl {
for (OrderDetail detail : orderDetails) { for (OrderDetail detail : orderDetails) {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
goodsList.add(jsonObject); goodsList.add(jsonObject);
jsonObject.put("goodsId", Long.valueOf(detail.getGoodsId())); jsonObject.put("goodsId", detail.getGoodsId());
jsonObject.put("goodsName",detail.getGoodsName()); jsonObject.put("goodsName",detail.getGoodsName());
jsonObject.put("num",Integer.parseInt(detail.getNum())); jsonObject.put("num",Integer.parseInt(detail.getNum()));
jsonObject.put("amount",detail.getAmount()); jsonObject.put("amount",detail.getViewAmount());
jsonObject.put("specRuleDetail",detail.getSpecRuleDetail()); jsonObject.put("specRuleDetail",detail.getSpecRuleDetail());
jsonObject.put("specRuleIds",detail.getSpecRuleIds()); jsonObject.put("specRuleIds",detail.getSpecRuleIds());
jsonObject.put("skuId",Long.parseLong(detail.getSkuId())); jsonObject.put("skuId", detail.getSkuId());
// if("0".equals(detail.getGoodsCategory())){ // if("0".equals(detail.getGoodsCategory())){
// jsonObject.put("goodsCategory","今日特惠"); // jsonObject.put("goodsCategory","今日特惠");
// }else{ // }else{
......
...@@ -2,7 +2,6 @@ package com.soss.system.service.impl; ...@@ -2,7 +2,6 @@ package com.soss.system.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.soss.common.constant.HttpStatus;
import com.soss.common.core.domain.AjaxResult; import com.soss.common.core.domain.AjaxResult;
import com.soss.common.core.domain.model.LoginUser; import com.soss.common.core.domain.model.LoginUser;
import com.soss.common.exception.ServiceException; import com.soss.common.exception.ServiceException;
...@@ -126,17 +125,6 @@ public class OrderServiceImpl implements IOrderService { ...@@ -126,17 +125,6 @@ public class OrderServiceImpl implements IOrderService {
@Override @Override
@Transactional @Transactional
public AjaxResult insertOrder(LoginUser loginUser, Order order) { public AjaxResult insertOrder(LoginUser loginUser, Order order) {
AjaxResult result = check(order);
if (HttpStatus.SUCCESS != (int) result.get(result.CODE_TAG)) {
return result;
}
try {
checkBusinessTime(order.getShopId());
} catch (ServiceException e) {
return AjaxResult.error(e.getMessage());
}
order.setState(OrderStatusConstant.Unpaid); order.setState(OrderStatusConstant.Unpaid);
order.setUserId(loginUser.getOpenId()); order.setUserId(loginUser.getOpenId());
order.setUserName(loginUser.getUsername()); order.setUserName(loginUser.getUsername());
...@@ -190,7 +178,8 @@ public class OrderServiceImpl implements IOrderService { ...@@ -190,7 +178,8 @@ public class OrderServiceImpl implements IOrderService {
} }
private void checkBusinessTime(String shopId) { @Override
public void checkBusinessTime(String shopId) {
Shop shop = shopMapper.selectShopById(shopId); Shop shop = shopMapper.selectShopById(shopId);
String startTime = shop.getStartTime(); String startTime = shop.getStartTime();
String endTime = shop.getEndTime(); String endTime = shop.getEndTime();
...@@ -206,8 +195,6 @@ public class OrderServiceImpl implements IOrderService { ...@@ -206,8 +195,6 @@ public class OrderServiceImpl implements IOrderService {
if (startBusiness.getTimeInMillis() > l || endBusiness.getTimeInMillis() < l) { if (startBusiness.getTimeInMillis() > l || endBusiness.getTimeInMillis() < l) {
throw new ServiceException("当前时间本店休息中,暂停点单~"); throw new ServiceException("当前时间本店休息中,暂停点单~");
} }
} }
/** /**
...@@ -415,7 +402,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -415,7 +402,7 @@ public class OrderServiceImpl implements IOrderService {
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
ShopGoodsSku shopGoodsSku = new ShopGoodsSku(); ShopGoodsSku shopGoodsSku = new ShopGoodsSku();
shopGoodsSku.setSkuId(Long.parseLong(orderDetail.getSkuId())); shopGoodsSku.setSkuId(orderDetail.getSkuId());
shopGoodsSku.setShopId(Long.valueOf(order.getShopId())); shopGoodsSku.setShopId(Long.valueOf(order.getShopId()));
shopGoodsSku.setIsDeleted("0"); shopGoodsSku.setIsDeleted("0");
List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku); List<ShopGoodsSku> shopGoodsSkus = shopGoodsSkuMapper.selectShopGoodsSkuList(shopGoodsSku);
...@@ -631,7 +618,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -631,7 +618,7 @@ public class OrderServiceImpl implements IOrderService {
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
orderDetail.setOrderId(Long.parseLong(orderId)); orderDetail.setOrderId(Long.parseLong(orderId));
List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail); List<OrderDetail> orderDetails = orderDetailMapper.selectOrderDetailList(orderDetail);
List<String> skuIds = orderDetails.stream().map(OrderDetail::getSkuId).collect(Collectors.toList()); List<Long> skuIds = orderDetails.stream().map(OrderDetail::getSkuId).collect(Collectors.toList());
OrderTakingVo infoByShop = orderTakingService.getInfoByShop(shopId); OrderTakingVo infoByShop = orderTakingService.getInfoByShop(shopId);
List<CategoryVo> categorys = infoByShop.getCategorys(); List<CategoryVo> categorys = infoByShop.getCategorys();
List<GoodsVo> ccs = new ArrayList<>(); List<GoodsVo> ccs = new ArrayList<>();
...@@ -650,7 +637,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -650,7 +637,7 @@ public class OrderServiceImpl implements IOrderService {
continue; continue;
} }
for (SkuVo skus : good.getSkus()) { for (SkuVo skus : good.getSkus()) {
if (skuIds.contains(skus.getSkuId())) { if (skuIds.contains(Long.parseLong(skus.getSkuId()))) {
skuVoList.add(skus); skuVoList.add(skus);
} }
} }
......
...@@ -262,10 +262,10 @@ public class ShopServiceImpl implements IShopService ...@@ -262,10 +262,10 @@ public class ShopServiceImpl implements IShopService
public String turn(Long shopId, Long goodsId, String pointer) { public String turn(Long shopId, Long goodsId, String pointer) {
ShopGoods shopGoods = new ShopGoods(); ShopGoods shopGoods = new ShopGoods();
shopGoods.setShopId(shopId); shopGoods.setShopId(shopId);
Goods goods = goodsMapper.selectGoodsById(String.valueOf(goodsId)); Goods goods = goodsMapper.selectGoodsById(goodsId);
List<ShopGoods> shopGoodsList = shopGoodsMapper.selectShopGoodsList(shopGoods); List<ShopGoods> shopGoodsList = shopGoodsMapper.selectShopGoodsList(shopGoods);
shopGoodsList = shopGoodsList.stream().filter(e->{ shopGoodsList = shopGoodsList.stream().filter(e->{
String category = goodsMapper.selectGoodsById(String.valueOf(e.getGoodsId())).getCategory(); String category = goodsMapper.selectGoodsById(e.getGoodsId()).getCategory();
if(category.equals(goods.getCategory())){ if(category.equals(goods.getCategory())){
return true; return true;
}else{ }else{
...@@ -392,7 +392,7 @@ public class ShopServiceImpl implements IShopService ...@@ -392,7 +392,7 @@ public class ShopServiceImpl implements IShopService
ShopGoodsSku shopGoodsSku1 = shopGoodsSkus.get(0); ShopGoodsSku shopGoodsSku1 = shopGoodsSkus.get(0);
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("state",shopGoodsSku1.getState()); jsonObject.put("state",shopGoodsSku1.getState());
Goods goods = goodsMapper.selectGoodsById(String.valueOf(shopGoodsSku1.getGoodsId())); Goods goods = goodsMapper.selectGoodsById(shopGoodsSku1.getGoodsId());
jsonObject.put("goods",getGoodsVo(goods,shopGoodsSku1.getShopId())); jsonObject.put("goods",getGoodsVo(goods,shopGoodsSku1.getShopId()));
return AjaxResult.success(jsonObject); return AjaxResult.success(jsonObject);
......
...@@ -6,31 +6,28 @@ import lombok.extern.slf4j.Slf4j; ...@@ -6,31 +6,28 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.FileCopyUtils;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Component @Component
@Slf4j @Slf4j
public class AreaUtil { public class AreaUtil {
// private Map<String, Area> areaMap; // private Map<String, Area> areaMap;
private Map<String, String> areaDeepMap = new HashMap<>(); private Map<String, String> provNameMap = new HashMap<>();
private Map<String, String> areaOrCityFullNameMap = new HashMap<>();
@PostConstruct @PostConstruct
public void init() { public void init() {
try { try {
ClassPathResource resource = new ClassPathResource("province.json"); ClassPathResource resource = new ClassPathResource("province.json");
BufferedReader bufferedReader = new BufferedReader(new FileReader(resource.getFile())); byte[] bdata = FileCopyUtils.copyToByteArray(resource.getInputStream());
StringBuilder builder = new StringBuilder(); String data = new String(bdata, StandardCharsets.UTF_8);
String line; JSONArray areaArray = JSONArray.parseArray(data);
while ((line = bufferedReader.readLine()) != null) {
builder.append(line);
}
JSONArray areaArray = JSONArray.parseArray(builder.toString());
// areaMap = buildAreaTree(areaArray); // areaMap = buildAreaTree(areaArray);
deepAreaTree(areaArray, ""); deepAreaTree(areaArray, "");
} catch (IOException e) { } catch (IOException e) {
...@@ -47,14 +44,22 @@ public class AreaUtil { ...@@ -47,14 +44,22 @@ public class AreaUtil {
String code = area.getString("value"); String code = area.getString("value");
String label = area.getString("label"); String label = area.getString("label");
String curLabel = parentName + label; String curLabel = parentName + label;
areaDeepMap.put(code, curLabel); if (parentName.equals("")) {
provNameMap.put(code, curLabel);
} else {
areaOrCityFullNameMap.put(code, curLabel);
}
JSONArray children = area.getJSONArray("children"); JSONArray children = area.getJSONArray("children");
deepAreaTree(children, curLabel); deepAreaTree(children, curLabel);
} }
} }
public String getAreaNameByCode(String code) { public String getProvNameByCode(String code) {
return areaDeepMap.get(code); return provNameMap.get(code);
}
public String getCityOrAreaNameByCode(String code) {
return areaOrCityFullNameMap.get(code);
} }
/*private Map<String, Area> buildAreaTree(JSONArray areaArray) { /*private Map<String, Area> buildAreaTree(JSONArray areaArray) {
......
...@@ -4,14 +4,30 @@ import com.soss.common.utils.StringUtils; ...@@ -4,14 +4,30 @@ import com.soss.common.utils.StringUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
public class CollectionUtil { public class ArrayUtil {
public static <T> void listAddArray(List<T> lst, T[] ts) { public static <T> void listAddArray(List<T> lst, T[] ts) {
if (hasContents(ts)) { if (hasContents(ts)) {
lst.addAll(Arrays.asList(ts)); lst.addAll(Arrays.asList(ts));
} }
} }
public static <T> boolean isAllAvailable(T[] ts) {
if (ts == null || ts.length != 1) {
return false;
}
T t = ts[0];
if (t instanceof String) {
return Objects.equals(t, "0");
} else if (t instanceof Integer) {
return Objects.equals(t, 0);
} else if (t instanceof Long) {
return Objects.equals(t, 0L);
}
return false;
}
public static <T> boolean hasContents(T[] ts) { public static <T> boolean hasContents(T[] ts) {
return ts != null && ts.length > 0; return ts != null && ts.length > 0;
} }
...@@ -20,10 +36,33 @@ public class CollectionUtil { ...@@ -20,10 +36,33 @@ public class CollectionUtil {
return StringUtils.isEmpty(codeStr) ? null : codeStr.split(","); return StringUtils.isEmpty(codeStr) ? null : codeStr.split(",");
} }
public static Integer[] transStrToIntList(String idsStr) {
if (StringUtils.isEmpty(idsStr)) {
return null;
}
return Arrays.stream(idsStr.split(",")).map(Integer::parseInt).toArray(Integer[]::new);
}
public static Long[] transStrToLongList(String idsStr) { public static Long[] transStrToLongList(String idsStr) {
if (StringUtils.isEmpty(idsStr)) { if (StringUtils.isEmpty(idsStr)) {
return null; return null;
} }
return Arrays.stream(idsStr.split(",")).map(Long::parseLong).toArray(Long[]::new); return Arrays.stream(idsStr.split(",")).map(Long::parseLong).toArray(Long[]::new);
} }
public static <T> boolean contains(T[] ts, T t) {
if (ts == null || ts.length == 0) {
return false;
}
for (T src : ts) {
if (Objects.equals(src, t)) {
return true;
}
}
return false;
}
public static <T> boolean isEmpty(T[] ts) {
return ts == null || ts.length == 0;
}
} }
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
<select id="listCustAvailableCoupon" resultType="com.soss.system.domain.vo.CouponVo"> <select id="listCustAvailableCoupon" 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 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 categoryIdStr, cr.goods_ids useStartTime, cu.expired_time useEndTime, cc.`desc` categoryDesc, cr.category_ids categoryIdStr, cr.goods_ids
goodsIdStr, cr.province provinceStr, cr.city cityStr, cr.area areaStr, cr.shop_ids shopIdStr goodsIdStr, cr.province provinceStr, cr.city cityStr, cr.area areaStr, cr.shop_ids shopIdStr,
cr.week_limit weekLimitStr
<include refid="selectCustAvailableCoupon"/> <include refid="selectCustAvailableCoupon"/>
</select> </select>
...@@ -44,7 +45,10 @@ ...@@ -44,7 +45,10 @@
left join coupon_category cc on c.category_id = cc.id left join coupon_category cc on c.category_id = cc.id
left join coupon_rule cr on c.rule_id = cr.id left join coupon_rule cr on c.rule_id = cr.id
where cu.cust_id = #{custId} and cr.use_start_time &lt; #{nowTime} and cu.expired_time > #{nowTime} where cu.cust_id = #{custId} and cr.use_start_time &lt; #{nowTime} and cu.expired_time > #{nowTime}
and cu.state = ${@com.soss.common.enums.CouponUserState @DEFAULT.getState} and cu.state = ${@com.soss.common.enums.CouponUserState @EFFECTIVE.getState}
<if test="couponId != null">
and c.id = #{couponId}
</if>
</sql> </sql>
<select id="selectCouponUserList" resultType="com.soss.system.domain.vo.CouponUserVo"> <select id="selectCouponUserList" resultType="com.soss.system.domain.vo.CouponUserVo">
......
...@@ -8,10 +8,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -8,10 +8,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" /> <result property="id" column="id" />
<result property="goodsId" column="goods_id" /> <result property="goodsId" column="goods_id" />
<result property="ruleList" column="rule_list" /> <result property="ruleList" column="rule_list" />
<result property="isDeleted" column="is_deleted" /> <result property="isDeleted" column="is_deleted"/>
<result property="createdAt" column="created_at" /> <result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at" /> <result property="updatedAt" column="updated_at"/>
<result property="price" column="price" /> <result property="price" column="price"/>
<result property="discount" column="discount"/> <result property="discount" column="discount"/>
</resultMap> </resultMap>
...@@ -19,15 +19,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -19,15 +19,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, goods_id, rule_list, is_deleted, created_at, updated_at, price,discount from goods_sku select id, goods_id, rule_list, is_deleted, created_at, updated_at, price,discount from goods_sku
</sql> </sql>
<select id="selectSkuListForOrder" resultMap="GoodsSkuResult">
select id, goods_id, discount from goods_sku where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach>
</select>
<select id="selectGoodsSkuList" parameterType="GoodsSku" resultMap="GoodsSkuResult"> <select id="selectGoodsSkuList" parameterType="GoodsSku" resultMap="GoodsSkuResult">
<include refid="selectGoodsSkuVo"/> <include refid="selectGoodsSkuVo"/>
<where> <where>
and is_deleted =0 and is_deleted =0
<if test="goodsId != null and goodsId != ''"> and goods_id = #{goodsId}</if> <if test="goodsId != null and goodsId != ''">and goods_id = #{goodsId}</if>
<if test="ruleList != null and ruleList != ''"> and rule_list = #{ruleList}</if> <if test="ruleList != null and ruleList != ''">and rule_list = #{ruleList}</if>
<if test="isDeleted != null and isDeleted != ''"> and is_deleted = #{isDeleted}</if> <if test="isDeleted != null and isDeleted != ''">and is_deleted = #{isDeleted}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="createdAt != null ">and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="updatedAt != null ">and updated_at = #{updatedAt}</if>
<if test="price != null "> and price = #{price}</if> <if test="price != null "> and price = #{price}</if>
<if test="discount != null "> and discount = #{discount}</if> <if test="discount != null "> and discount = #{discount}</if>
</where> </where>
......
...@@ -11,7 +11,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -11,7 +11,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="goodsName" column="goods_name" /> <result property="goodsName" column="goods_name" />
<result property="machineId" column="machine_id" /> <result property="machineId" column="machine_id" />
<result property="num" column="num" /> <result property="num" column="num" />
<result property="amount" column="amount" /> <result property="viewAmount" column="view_amount" />
<result property="amountShould" column="amount_should" />
<result property="couponAmount" column="coupon_amount" />
<result property="realAmount" column="real_amount" /> <result property="realAmount" column="real_amount" />
<result property="specRuleDetail" column="spec_rule_detail" /> <result property="specRuleDetail" column="spec_rule_detail" />
<result property="specRuleIds" column="spec_rule_ids" /> <result property="specRuleIds" column="spec_rule_ids" />
...@@ -33,7 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -33,7 +35,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if> <if test="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="machineId != null and machineId != ''"> and machine_id = #{machineId}</if> <if test="machineId != null and machineId != ''"> and machine_id = #{machineId}</if>
<if test="num != null and num != ''"> and num = #{num}</if> <if test="num != null and num != ''"> and num = #{num}</if>
<if test="amount != null "> and amount = #{amount}</if> <if test="viewAmount != null "> and view_amount = #{viewAmount}</if>
<if test="amountShould != null "> and amount_should = #{amountShould}</if>
<if test="couponAmount != null "> and coupon_amount = #{couponAmount}</if>
<if test="realAmount != null "> and real_amount = #{realAmount}</if> <if test="realAmount != null "> and real_amount = #{realAmount}</if>
<if test="specRuleDetail != null and specRuleDetail != ''"> and spec_rule_detail = #{specRuleDetail}</if> <if test="specRuleDetail != null and specRuleDetail != ''"> and spec_rule_detail = #{specRuleDetail}</if>
<if test="specRuleIds != null and specRuleIds != ''"> and spec_rule_ids = #{specRuleIds}</if> <if test="specRuleIds != null and specRuleIds != ''"> and spec_rule_ids = #{specRuleIds}</if>
...@@ -57,7 +61,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -57,7 +61,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsName != null and goodsName != ''">goods_name,</if> <if test="goodsName != null and goodsName != ''">goods_name,</if>
<if test="machineId != null and machineId != ''">machine_id,</if> <if test="machineId != null and machineId != ''">machine_id,</if>
<if test="num != null and num != ''">num,</if> <if test="num != null and num != ''">num,</if>
<if test="amount != null">amount,</if> <if test="viewAmount != null">view_amount,</if>
<if test="amountShould != null">amount_should,</if>
<if test="couponAmount != null">coupon_amount,</if>
<if test="realAmount != null">real_amount,</if> <if test="realAmount != null">real_amount,</if>
<if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail,</if> <if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail,</if>
<if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids,</if> <if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids,</if>
...@@ -72,7 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -72,7 +78,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsName != null and goodsName != ''">#{goodsName},</if> <if test="goodsName != null and goodsName != ''">#{goodsName},</if>
<if test="machineId != null and machineId != ''">#{machineId},</if> <if test="machineId != null and machineId != ''">#{machineId},</if>
<if test="num != null and num != ''">#{num},</if> <if test="num != null and num != ''">#{num},</if>
<if test="amount != null">#{amount},</if> <if test="viewAmount != null">#{viewAmount},</if>
<if test="amountShould != null">#{amountShould},</if>
<if test="couponAmount != null">#{couponAmount},</if>
<if test="realAmount != null">#{realAmount},</if> <if test="realAmount != null">#{realAmount},</if>
<if test="specRuleDetail != null and specRuleDetail != ''">#{specRuleDetail},</if> <if test="specRuleDetail != null and specRuleDetail != ''">#{specRuleDetail},</if>
<if test="specRuleIds != null and specRuleIds != ''">#{specRuleIds},</if> <if test="specRuleIds != null and specRuleIds != ''">#{specRuleIds},</if>
...@@ -91,7 +99,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -91,7 +99,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if> <if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="machineId != null and machineId != ''">machine_id = #{machineId},</if> <if test="machineId != null and machineId != ''">machine_id = #{machineId},</if>
<if test="num != null and num != ''">num = #{num},</if> <if test="num != null and num != ''">num = #{num},</if>
<if test="amount != null">amount = #{amount},</if> <if test="viewAmount != null">view_amount = #{viewAmount},</if>
<if test="amountShould != null">amount_should = #{amountShould},</if>
<if test="couponAmount != null">coupon_amount = #{couponAmount},</if>
<if test="realAmount != null">real_amount = #{realAmount},</if> <if test="realAmount != null">real_amount = #{realAmount},</if>
<if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail = #{specRuleDetail},</if> <if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail = #{specRuleDetail},</if>
<if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids = #{specRuleIds},</if> <if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids = #{specRuleIds},</if>
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.soss.system.mapper.OrderMapper"> <mapper namespace="com.soss.system.mapper.OrderMapper">
<resultMap type="Order" id="OrderResult"> <resultMap type="Order" id="OrderResult">
...@@ -14,6 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -14,6 +14,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="payTime" column="pay_time" /> <result property="payTime" column="pay_time" />
<result property="finishTime" column="finish_time" /> <result property="finishTime" column="finish_time" />
<result property="amount" column="amount" /> <result property="amount" column="amount" />
<result property="couponId" column="coupon_id" />
<result property="couponAmount" column="coupon_amount" />
<result property="paidAmount" column="paid_amount" />
<result property="goodsNum" column="goods_num" /> <result property="goodsNum" column="goods_num" />
<result property="pickCode" column="pick_code" /> <result property="pickCode" column="pick_code" />
<result property="shopId" column="shop_id" /> <result property="shopId" column="shop_id" />
...@@ -39,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -39,6 +42,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payTime != null "> and pay_time = #{payTime}</if> <if test="payTime != null "> and pay_time = #{payTime}</if>
<if test="finishTime != null "> and finish_time = #{finishTime}</if> <if test="finishTime != null "> and finish_time = #{finishTime}</if>
<if test="amount != null "> and amount = #{amount}</if> <if test="amount != null "> and amount = #{amount}</if>
<if test="couponId != null "> and coupon_id = #{couponId}</if>
<if test="couponAmount != null "> and coupon_amount = #{couponAmount}</if>
<if test="paidAmount != null "> and paid_amount = #{paidAmount}</if>
<if test="goodsNum != null and goodsNum != ''"> and goods_num = #{goodsNum}</if> <if test="goodsNum != null and goodsNum != ''"> and goods_num = #{goodsNum}</if>
<if test="pickCode != null and pickCode != ''"> and pick_code = #{pickCode}</if> <if test="pickCode != null and pickCode != ''"> and pick_code = #{pickCode}</if>
<if test="shopId != null and shopId != ''"> and shop_id = #{shopId}</if> <if test="shopId != null and shopId != ''"> and shop_id = #{shopId}</if>
...@@ -67,6 +73,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -67,6 +73,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payTime != null">pay_time,</if> <if test="payTime != null">pay_time,</if>
<if test="finishTime != null">finish_time,</if> <if test="finishTime != null">finish_time,</if>
<if test="amount != null">amount,</if> <if test="amount != null">amount,</if>
<if test="couponId != null">coupon_id,</if>
<if test="couponAmount != null">coupon_amount,</if>
<if test="paidAmount != null">paid_amount,</if>
<if test="goodsNum != null and goodsNum != ''">goods_num,</if> <if test="goodsNum != null and goodsNum != ''">goods_num,</if>
<if test="pickCode != null and pickCode != ''">pick_code,</if> <if test="pickCode != null and pickCode != ''">pick_code,</if>
<if test="shopId != null and shopId != ''">shop_id,</if> <if test="shopId != null and shopId != ''">shop_id,</if>
...@@ -85,6 +94,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -85,6 +94,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payTime != null">#{payTime},</if> <if test="payTime != null">#{payTime},</if>
<if test="finishTime != null">#{finishTime},</if> <if test="finishTime != null">#{finishTime},</if>
<if test="amount != null">#{amount},</if> <if test="amount != null">#{amount},</if>
<if test="couponId != null">#{couponId},</if>
<if test="couponAmount != null">#{couponAmount},</if>
<if test="paidAmount != null">#{paidAmount},</if>
<if test="goodsNum != null and goodsNum != ''">#{goodsNum},</if> <if test="goodsNum != null and goodsNum != ''">#{goodsNum},</if>
<if test="pickCode != null and pickCode != ''">#{pickCode},</if> <if test="pickCode != null and pickCode != ''">#{pickCode},</if>
<if test="shopId != null and shopId != ''">#{shopId},</if> <if test="shopId != null and shopId != ''">#{shopId},</if>
...@@ -107,6 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -107,6 +119,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="payTime != null">pay_time = #{payTime},</if> <if test="payTime != null">pay_time = #{payTime},</if>
<if test="finishTime != null">finish_time = #{finishTime},</if> <if test="finishTime != null">finish_time = #{finishTime},</if>
<if test="amount != null">amount = #{amount},</if> <if test="amount != null">amount = #{amount},</if>
<if test="couponId != null">coupon_id = #{couponId},</if>
<if test="couponAmount != null">coupon_amount = #{couponAmount},</if>
<if test="paidAmount != null">paid_amount = #{paidAmount},</if>
<if test="goodsNum != null and goodsNum != ''">goods_num = #{goodsNum},</if> <if test="goodsNum != null and goodsNum != ''">goods_num = #{goodsNum},</if>
<if test="pickCode != null and pickCode != ''">pick_code = #{pickCode},</if> <if test="pickCode != null and pickCode != ''">pick_code = #{pickCode},</if>
<if test="shopId != null and shopId != ''">shop_id = #{shopId},</if> <if test="shopId != null and shopId != ''">shop_id = #{shopId},</if>
...@@ -278,4 +293,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -278,4 +293,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateCancel"> <update id="updateCancel">
update `order` set state='8' where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND) update `order` set state='8' where state =#{status} and updated_at &lt; DATE_SUB(NOW() ,interval #{timeout} SECOND)
</update> </update>
<select id="getCustOrderSimpleStat" resultType="java.util.Map">
select count(*) orderCount, sum(amount) orderAmount from `order` where user_id = #{custId}
</select>
</mapper> </mapper>
\ No newline at end of file
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