1.2.3 后台操作按钮调整及其新增开启拼团功能
This commit is contained in:
BIN
Alibaba-PuHuiTi-Regular.otf
Normal file
BIN
Alibaba-PuHuiTi-Regular.otf
Normal file
Binary file not shown.
@ -7,12 +7,12 @@ yshop基于当前流行技术组合: SpringBoot2+Jpa+MybatisPlus+SpringSecurit
|
||||
|
||||
**开发文档** 【[查看文档](https://gitee.com/guchengwuyue/yshopmall/wikis/%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83?sort_id=1718722)】
|
||||
|
||||
#### 体验地址(手机体验最好用公众号,因为H5模式不支持微信支付,只有余额支付)
|
||||
#### 体验地址
|
||||
|
||||
| | 后台系统 | 前端(公众号)及H5 |
|
||||
| | 后台系统 | 前端(公众号) |
|
||||
|--- |--- | --- |
|
||||
| | https://yshop.dayouqiantu.cn | https://h5.dayouqiantu.cn |
|
||||
| | 后台体验账号/密码:admin/123456 | 公众号: |
|
||||
| | https://yshop.dayouqiantu.cn |g公众号:YshopMall |
|
||||
| | 后台体验账号/密码:admin/123456 | 公众号: |
|
||||
|
||||
|
||||
#### 项目源码
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
|
||||
<modules>
|
||||
<module>yshop-common</module>
|
||||
|
||||
@ -1 +1 @@
|
||||
nohup java -jar yshop-api-1.0.jar --spring.profiles.active=prod &
|
||||
nohup java -jar yshop-api-1.2.jar --spring.profiles.active=prod &
|
||||
@ -1,4 +1,4 @@
|
||||
PID=$(ps -ef | grep yshop-api-1.0.jar | grep -v grep | awk '{ print $2 }')
|
||||
PID=$(ps -ef | grep yshop-api-1.2.jar | grep -v grep | awk '{ print $2 }')
|
||||
if [ -z "$PID" ];then
|
||||
echo Application is already stopped
|
||||
else
|
||||
|
||||
BIN
simsunb.ttf
Normal file
BIN
simsunb.ttf
Normal file
Binary file not shown.
6045
sql/yxshop.sql
Normal file
6045
sql/yxshop.sql
Normal file
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -21,18 +21,18 @@
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-tools</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<artifactId>yshop-mp</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--jwt-->
|
||||
@ -88,6 +88,11 @@
|
||||
<artifactId>p6spy</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>redis.clients</groupId>-->
|
||||
<!-- <artifactId>jedis</artifactId>-->
|
||||
|
||||
@ -2,5 +2,6 @@ package co.yixiang.common.constant;
|
||||
|
||||
|
||||
public interface CacheKey {
|
||||
String ORDER_CANCEL_JOB = "order_cancel_job";
|
||||
|
||||
}
|
||||
|
||||
@ -55,8 +55,8 @@ public class SwaggerConfig {
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("eladmin 接口文档")
|
||||
.version("2.1")
|
||||
.title("yshop 接口文档")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -57,8 +57,8 @@ public class SwaggerConfig2 {
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("eladmin 接口文档2")
|
||||
.version("2.1")
|
||||
.title("yshop 接口文档")
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,16 @@ import java.util.List;
|
||||
*/
|
||||
public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
|
||||
|
||||
void regressionCoupon(YxStoreOrderQueryVo order);
|
||||
|
||||
void regressionStock(YxStoreOrderQueryVo order);
|
||||
|
||||
void regressionIntegral(YxStoreOrderQueryVo order);
|
||||
|
||||
void cancelOrder(String orderId,int uid);
|
||||
|
||||
void cancelOrderByTask(int id);
|
||||
|
||||
void orderApplyRefund(RefundParam param,int uid);
|
||||
|
||||
void removeOrder(String orderId,int uid);
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package co.yixiang.modules.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
import co.yixiang.common.constant.CacheKey;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.monitor.service.RedisService;
|
||||
import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
@ -21,15 +19,20 @@ import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCart;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponUser;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCartMapper;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCouponUserMapper;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductService;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
//import co.yixiang.modules.task.CancelOrderService;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxUserAddress;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.entity.YxWechatUser;
|
||||
import co.yixiang.modules.user.mapper.YxUserMapper;
|
||||
import co.yixiang.modules.user.service.YxUserAddressService;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
@ -38,14 +41,22 @@ import co.yixiang.modules.user.web.controller.UserAddressController;
|
||||
import co.yixiang.modules.user.web.vo.YxUserAddressQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxWechatUserQueryVo;
|
||||
//import co.yixiang.redisson.DelayJob;
|
||||
//import co.yixiang.redisson.DelayJobService;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
//import org.redisson.RedissonDelayedQueue;
|
||||
//import org.redisson.api.RDelayedQueue;
|
||||
//import org.redisson.api.RQueue;
|
||||
//import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -54,9 +65,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Array;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
@ -114,6 +128,161 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
@Autowired
|
||||
private YxWechatUserService wechatUserService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponUserService couponUserService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponUserMapper yxStoreCouponUserMapper;
|
||||
|
||||
// @Autowired
|
||||
// private DelayJobService delayJobService;
|
||||
|
||||
|
||||
@Value("${job.unpayorder}")
|
||||
private String overtime;
|
||||
|
||||
/**
|
||||
* 退回优惠券
|
||||
* @param order
|
||||
*/
|
||||
@Override
|
||||
public void regressionCoupon(YxStoreOrderQueryVo order) {
|
||||
if(order.getPaid() > 0 || order.getStatus() == -2 || order.getIsDel() ==1){
|
||||
return;
|
||||
}
|
||||
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
if(order.getCouponId() > 0){
|
||||
wrapper.eq("id",order.getCouponId()).eq("status",1).eq("uid",order.getUid());
|
||||
YxStoreCouponUser couponUser = yxStoreCouponUserMapper.selectOne(wrapper);
|
||||
|
||||
if(ObjectUtil.isNotNull(couponUser)){
|
||||
YxStoreCouponUser storeCouponUser = new YxStoreCouponUser();
|
||||
QueryWrapper<YxStoreCouponUser> wrapperT= new QueryWrapper<>();
|
||||
wrapperT.eq("id",order.getCouponId()).eq("uid",order.getUid());
|
||||
storeCouponUser.setStatus(0);
|
||||
storeCouponUser.setUseTime(0);
|
||||
yxStoreCouponUserMapper.update(storeCouponUser,wrapperT);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回库存
|
||||
* @param order
|
||||
*/
|
||||
@Override
|
||||
public void regressionStock(YxStoreOrderQueryVo order) {
|
||||
if(order.getPaid() > 0 || order.getStatus() == -2 || order.getIsDel() ==1){
|
||||
return;
|
||||
}
|
||||
QueryWrapper<YxStoreOrderCartInfo> wrapper= new QueryWrapper<>();
|
||||
wrapper.in("cart_id", Arrays.asList(order.getCartId().split(",")));
|
||||
|
||||
List<YxStoreOrderCartInfo> cartInfoList = orderCartInfoService.list(wrapper);
|
||||
for (YxStoreOrderCartInfo cartInfo : cartInfoList) {
|
||||
YxStoreCartQueryVo cart = JSONObject.parseObject(cartInfo.getCartInfo()
|
||||
,YxStoreCartQueryVo.class);
|
||||
productService.incProductStock(cart.getCartNum(),cart.getProductId()
|
||||
,cart.getProductAttrUnique());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回积分
|
||||
* @param order
|
||||
*/
|
||||
@Override
|
||||
public void regressionIntegral(YxStoreOrderQueryVo order) {
|
||||
if(order.getPaid() > 0 || order.getStatus() == -2 || order.getIsDel() ==1){
|
||||
return;
|
||||
}
|
||||
if(order.getUseIntegral().doubleValue() <= 0) return;
|
||||
|
||||
if(order.getStatus() != -2 && order.getRefundStatus() != 2
|
||||
&& ObjectUtil.isNotNull(order.getBackIntegral())
|
||||
&& order.getBackIntegral().doubleValue() >= order.getUseIntegral().doubleValue()){
|
||||
return;
|
||||
}
|
||||
|
||||
YxUserQueryVo userQueryVo = userService
|
||||
.getYxUserById(order.getUid());
|
||||
|
||||
//增加积分
|
||||
userService.incIntegral(order.getUid(),order.getUseIntegral().doubleValue());
|
||||
|
||||
//增加流水
|
||||
YxUserBill userBill = new YxUserBill();
|
||||
userBill.setUid(order.getUid());
|
||||
userBill.setTitle("积分回退");
|
||||
userBill.setLinkId(order.getId().toString());
|
||||
userBill.setCategory("integral");
|
||||
userBill.setType("deduction");
|
||||
userBill.setNumber(order.getUseIntegral());
|
||||
userBill.setBalance(userQueryVo.getIntegral());
|
||||
userBill.setMark("购买商品失败,回退积分");
|
||||
userBill.setStatus(1);
|
||||
userBill.setPm(1);
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
//更新回退积分
|
||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||
storeOrder.setBackIntegral(order.getUseIntegral());
|
||||
storeOrder.setId(order.getId());
|
||||
yxStoreOrderMapper.updateById(storeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未付款取消订单
|
||||
* @param orderId
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public void cancelOrder(String orderId, int uid) {
|
||||
YxStoreOrderQueryVo order = getOrderInfo(orderId,uid);
|
||||
if(ObjectUtil.isNull(order)) throw new ErrorRequestException("订单不存在");
|
||||
|
||||
regressionIntegral(order);
|
||||
|
||||
regressionStock(order);
|
||||
|
||||
regressionCoupon(order);
|
||||
|
||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||
storeOrder.setIsDel(1);
|
||||
storeOrder.setId(order.getId());
|
||||
yxStoreOrderMapper.updateById(storeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统自动主动取消未付款取消订单
|
||||
* @param orderId
|
||||
*/
|
||||
@Override
|
||||
public void cancelOrderByTask(int orderId) {
|
||||
YxStoreOrderQueryVo order = null;
|
||||
try {
|
||||
order = getYxStoreOrderById(orderId);
|
||||
|
||||
if(ObjectUtil.isNull(order)) throw new ErrorRequestException("订单不存在");
|
||||
|
||||
regressionIntegral(order);
|
||||
|
||||
regressionStock(order);
|
||||
|
||||
regressionCoupon(order);
|
||||
|
||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||
storeOrder.setIsDel(1);
|
||||
storeOrder.setId(order.getId());
|
||||
yxStoreOrderMapper.updateById(storeOrder);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 奖励积分
|
||||
@ -198,7 +367,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
//奖励积分
|
||||
gainUserIntegral(order);
|
||||
|
||||
//todo 分销计算
|
||||
//分销计算
|
||||
userService.backOrderBrokerage(order);
|
||||
|
||||
}
|
||||
|
||||
@ -267,7 +437,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
break;
|
||||
case -3://退款
|
||||
String[] strs = {"1","2"};
|
||||
wrapper.eq("paid",1).in("refund_status",strs);
|
||||
wrapper.eq("paid",1).in("refund_status",Arrays.asList(strs));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -335,7 +505,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
QueryWrapper<YxStoreOrder> wrapperSeven= new QueryWrapper<>();
|
||||
String[] strArr = {"1","2"};
|
||||
wrapperSeven.eq("is_del",0).eq("paid",1)
|
||||
.eq("uid",uid).in("refund_status",strArr);
|
||||
.eq("uid",uid).in("refund_status",Arrays.asList(strArr));
|
||||
countDTO.setRefundCount(yxStoreOrderMapper.selectCount(wrapperSeven));
|
||||
|
||||
|
||||
@ -438,6 +608,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
//增加状态
|
||||
orderStatusService.create(orderInfo.getId(),"pay_success","用户付款成功");
|
||||
|
||||
|
||||
//todo 拼团
|
||||
//todo 模板消息推送
|
||||
}
|
||||
@ -448,6 +619,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
*/
|
||||
@Override
|
||||
public WxPayMpOrderResult wxPay(String orderId) throws WxPayException {
|
||||
String apiUrl = systemConfigService.getData("api_url");
|
||||
if(StrUtil.isBlank(apiUrl)) throw new ErrorRequestException("请配置api地址");
|
||||
YxStoreOrderQueryVo orderInfo = getOrderInfo(orderId,0);
|
||||
if(ObjectUtil.isNull(orderInfo)) throw new ErrorRequestException("订单不存在");
|
||||
if(orderInfo.getPaid() == 1) throw new ErrorRequestException("该订单已支付");
|
||||
@ -463,7 +636,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
orderRequest.setTotalFee(bigDecimal.multiply(orderInfo.getPayPrice()).intValue());//元转成分
|
||||
orderRequest.setOpenid(wechatUser.getOpenid());
|
||||
orderRequest.setSpbillCreateIp("127.0.0.1");
|
||||
orderRequest.setNotifyUrl("https://h5api.dayouqiantu.cn/api/wechat/notify");
|
||||
orderRequest.setNotifyUrl(apiUrl+"/api/wechat/notify");
|
||||
orderRequest.setTradeType("JSAPI");
|
||||
|
||||
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
||||
@ -556,22 +729,83 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
gainIntegral = NumberUtil.add(gainIntegral,cartInfoGainIntegral).intValue();
|
||||
}
|
||||
|
||||
//todo 优惠券
|
||||
int couponId = 0;
|
||||
Double couponPrice = 0d;
|
||||
if(ObjectUtil.isNotEmpty(param.getCouponId())){
|
||||
//todo
|
||||
}
|
||||
|
||||
//todo 门店等二期
|
||||
|
||||
if(param.getShippingType() == 1){
|
||||
payPrice = NumberUtil.add(payPrice,payPostage);
|
||||
}
|
||||
|
||||
//todo 积分抵扣
|
||||
//优惠券
|
||||
int couponId = 0;
|
||||
if(ObjectUtil.isNotEmpty(param.getCouponId())){
|
||||
couponId = param.getCouponId().intValue();
|
||||
}
|
||||
|
||||
int useIntegral = param.getUseIntegral().intValue();
|
||||
|
||||
boolean deduction = false;//todo 拼团等
|
||||
if(deduction){
|
||||
couponId = 0;
|
||||
useIntegral = 0;
|
||||
}
|
||||
double couponPrice = 0; //优惠券金额
|
||||
if(couponId > 0){//使用优惠券
|
||||
YxStoreCouponUser couponUser = couponUserService.getCoupon(couponId,uid);
|
||||
if(ObjectUtil.isNull(couponUser)) throw new ErrorRequestException("使用优惠劵失败");
|
||||
|
||||
if(couponUser.getUseMinPrice().doubleValue() > payPrice){
|
||||
throw new ErrorRequestException("不满足优惠劵的使用条件");
|
||||
}
|
||||
payPrice = NumberUtil.sub(payPrice,couponUser.getCouponPrice()).doubleValue();
|
||||
|
||||
couponUserService.useCoupon(couponId);//更新优惠券状态
|
||||
|
||||
couponPrice = couponUser.getCouponPrice().doubleValue();
|
||||
|
||||
}
|
||||
// 积分抵扣
|
||||
double deductionPrice = 0; //抵扣金额
|
||||
double usedIntegral = 0; //使用的积分
|
||||
if(useIntegral > 0 && userInfo.getIntegral().doubleValue() > 0){
|
||||
deductionPrice = NumberUtil.mul(userInfo.getIntegral(),
|
||||
Double.valueOf(cacheDTO.getOther().getIntegralRatio())).doubleValue();
|
||||
if(deductionPrice < payPrice){
|
||||
payPrice = NumberUtil.sub(payPrice.doubleValue(),deductionPrice);
|
||||
usedIntegral = userInfo.getIntegral().doubleValue();
|
||||
YxUser yxUser = new YxUser();
|
||||
yxUser.setIntegral(BigDecimal.ZERO);
|
||||
yxUser.setUid(uid);
|
||||
userService.updateById(yxUser);
|
||||
}else{
|
||||
deductionPrice = payPrice;
|
||||
usedIntegral = NumberUtil.div(payPrice,
|
||||
Double.valueOf(cacheDTO.getOther().getIntegralRatio()));
|
||||
userService.decIntegral(uid,usedIntegral);
|
||||
payPrice = 0d;
|
||||
|
||||
}
|
||||
|
||||
//积分流水
|
||||
YxUserBill userBill = new YxUserBill();
|
||||
userBill.setUid(uid);
|
||||
userBill.setTitle("积分抵扣");
|
||||
userBill.setLinkId(key);
|
||||
userBill.setCategory("integral");
|
||||
userBill.setType("deduction");
|
||||
userBill.setNumber(BigDecimal.valueOf(usedIntegral));
|
||||
userBill.setBalance(userInfo.getIntegral());
|
||||
userBill.setMark("购买商品使用");
|
||||
userBill.setStatus(1);
|
||||
userBill.setPm(0);
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
}
|
||||
|
||||
if(payPrice <= 0) payPrice = 0d;
|
||||
|
||||
|
||||
//组合数据
|
||||
YxStoreOrder storeOrder = new YxStoreOrder();
|
||||
storeOrder.setUid(uid);
|
||||
@ -588,10 +822,10 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
storeOrder.setCouponPrice(BigDecimal.valueOf(couponPrice));
|
||||
storeOrder.setPayPrice(BigDecimal.valueOf(payPrice));
|
||||
storeOrder.setPayPostage(BigDecimal.valueOf(payPostage));
|
||||
storeOrder.setDeductionPrice(BigDecimal.ZERO);
|
||||
storeOrder.setDeductionPrice(BigDecimal.valueOf(deductionPrice));
|
||||
storeOrder.setPaid(0);
|
||||
storeOrder.setPayType(param.getPayType());
|
||||
storeOrder.setUseIntegral(BigDecimal.valueOf(param.getUseIntegral()));
|
||||
storeOrder.setUseIntegral(BigDecimal.valueOf(usedIntegral));
|
||||
storeOrder.setGainIntegral(BigDecimal.valueOf(gainIntegral));
|
||||
storeOrder.setMark(param.getMark());
|
||||
storeOrder.setCombinationId(0);
|
||||
@ -629,7 +863,17 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
//增加状态
|
||||
orderStatusService.create(storeOrder.getId(),"cache_key_create_order","订单生成");
|
||||
|
||||
// 订单支付超期任务
|
||||
|
||||
//String overtimeStr = systemConfigService.getData("order_cancel_job_time");
|
||||
//没有配置不加入
|
||||
// if(StrUtil.isNotBlank(overtimeStr)){
|
||||
// // 订单支付超期任务
|
||||
// DelayJob delayJob = new DelayJob();
|
||||
// delayJob.setOrderId(storeOrder.getId());
|
||||
// delayJob.setAClass(CancelOrderService.class);
|
||||
// delayJobService.submitJob(delayJob,Long.valueOf(overtimeStr));
|
||||
// }
|
||||
|
||||
return storeOrder;
|
||||
}
|
||||
@ -645,6 +889,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
@Override
|
||||
public ComputeDTO computedOrder(int uid, String key, int couponId,
|
||||
int useIntegral, int shippingType) {
|
||||
YxUserQueryVo userInfo = userService.getYxUserById(uid);
|
||||
if(ObjectUtil.isNull(userInfo)) throw new ErrorRequestException("用户不存在");
|
||||
CacheDTO cacheDTO = getCacheOrderInfo(uid,key);
|
||||
if(ObjectUtil.isNull(cacheDTO)){
|
||||
throw new ErrorRequestException("订单已过期,请刷新当前页面");
|
||||
@ -653,13 +899,46 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
|
||||
computeDTO.setTotalPrice(cacheDTO.getPriceGroup().getTotalPrice());
|
||||
Double payPrice = cacheDTO.getPriceGroup().getTotalPrice();
|
||||
Double payPostage = cacheDTO.getPriceGroup().getStorePostage();
|
||||
//todo 优惠券
|
||||
|
||||
//todo 积分抵扣
|
||||
boolean deduction = false;//todo 拼团等
|
||||
if(deduction){
|
||||
couponId = 0;
|
||||
useIntegral = 0;
|
||||
}
|
||||
double couponPrice = 0;
|
||||
if(couponId > 0){//使用优惠券
|
||||
YxStoreCouponUser couponUser = couponUserService.getCoupon(couponId,uid);
|
||||
if(ObjectUtil.isNull(couponUser)) throw new ErrorRequestException("使用优惠劵失败");
|
||||
|
||||
if(couponUser.getUseMinPrice().doubleValue() > payPrice){
|
||||
throw new ErrorRequestException("不满足优惠劵的使用条件");
|
||||
}
|
||||
payPrice = NumberUtil.sub(payPrice,couponUser.getCouponPrice()).doubleValue();
|
||||
|
||||
couponPrice = couponUser.getCouponPrice().doubleValue();
|
||||
|
||||
}
|
||||
|
||||
// 积分抵扣
|
||||
double deductionPrice = 0;
|
||||
if(useIntegral > 0 && userInfo.getIntegral().doubleValue() > 0){
|
||||
deductionPrice = NumberUtil.mul(userInfo.getIntegral(),
|
||||
Double.valueOf(cacheDTO.getOther().getIntegralRatio())).doubleValue();
|
||||
if(deductionPrice < payPrice){
|
||||
payPrice = NumberUtil.sub(payPrice.doubleValue(),deductionPrice);
|
||||
}else{
|
||||
deductionPrice = payPrice;
|
||||
payPrice = 0d;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(payPrice <= 0) payPrice = 0d;
|
||||
|
||||
computeDTO.setPayPrice(payPrice);
|
||||
computeDTO.setPayPostage(payPostage);
|
||||
computeDTO.setCouponPrice(0d);
|
||||
computeDTO.setDeductionPrice(0d);
|
||||
computeDTO.setCouponPrice(couponPrice);
|
||||
computeDTO.setDeductionPrice(deductionPrice);
|
||||
|
||||
return computeDTO;
|
||||
}
|
||||
|
||||
@ -20,7 +20,9 @@ import co.yixiang.modules.order.web.param.YxStoreOrderQueryParam;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.modules.shop.entity.YxStoreProductReply;
|
||||
import co.yixiang.modules.shop.service.YxStoreCartService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.shop.service.YxStoreProductReplyService;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import co.yixiang.modules.user.service.YxUserAddressService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
@ -62,6 +64,8 @@ public class StoreOrderController extends BaseController {
|
||||
private final YxStoreOrderCartInfoService orderCartInfoService;
|
||||
private final YxStoreProductReplyService productReplyService;
|
||||
private final YxStoreOrderStatusService orderStatusService;
|
||||
private final YxStoreCouponUserService couponUserService;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
|
||||
|
||||
/**
|
||||
@ -88,19 +92,20 @@ public class StoreOrderController extends BaseController {
|
||||
|
||||
ConfirmOrderDTO confirmOrderDTO = new ConfirmOrderDTO();
|
||||
|
||||
//todo 积分抵扣下个版本
|
||||
|
||||
//todo 优惠券抵扣下个版本
|
||||
confirmOrderDTO.setUsableCoupon(couponUserService
|
||||
.beUsableCoupon(uid,priceGroup.getTotalPrice()));
|
||||
//todo 积分抵扣下个版本 已经do
|
||||
OtherDTO other = new OtherDTO();
|
||||
other.setIntegralRatio(systemConfigService.getData("integral_ratio"));
|
||||
|
||||
//todo 拼团 砍价 秒杀
|
||||
|
||||
//todo 地址信息
|
||||
confirmOrderDTO.setAddressInfo(addressService.getUserDefaultAddress(uid));
|
||||
|
||||
confirmOrderDTO.setCartInfo(cartInfo);
|
||||
confirmOrderDTO.setPriceGroup(priceGroup);
|
||||
confirmOrderDTO.setOrderKey(storeOrderService.cacheOrderInfo(uid,cartInfo,
|
||||
priceGroup,new OtherDTO()));
|
||||
priceGroup,other));
|
||||
//todo VIP会员
|
||||
|
||||
confirmOrderDTO.setUserInfo(userService.getYxUserById(uid));
|
||||
@ -304,10 +309,13 @@ public class StoreOrderController extends BaseController {
|
||||
String useIntegral = jsonObject.getString("useIntegral");
|
||||
//todo 砍价
|
||||
//todo 拼团
|
||||
ComputeDTO computeDTO = storeOrderService.computedOrder(uid,key,Integer.valueOf(couponId),
|
||||
Integer.valueOf(useIntegral),Integer.valueOf(shippingType));
|
||||
ComputeDTO computeDTO = storeOrderService.computedOrder(uid,key,
|
||||
Integer.valueOf(couponId),
|
||||
Integer.valueOf(useIntegral),
|
||||
Integer.valueOf(shippingType));
|
||||
|
||||
map.put("result",computeDTO);
|
||||
map.put("status","NONE");
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
@ -454,5 +462,21 @@ public class StoreOrderController extends BaseController {
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单取消 未支付的订单回退积分,回退优惠券,回退库存
|
||||
*/
|
||||
@PostMapping("/order/cancel")
|
||||
@ApiOperation(value = "订单取消",notes = "订单取消")
|
||||
public ApiResult<Object> cancelOrder(@RequestBody String jsonStr){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
String orderId = jsonObject.getString("id");
|
||||
if(StrUtil.isEmpty(orderId)) return ApiResult.fail("参数错误");
|
||||
|
||||
storeOrderService.cancelOrder(orderId,uid);
|
||||
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.order.web.dto;
|
||||
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponUser;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import co.yixiang.modules.user.entity.YxUserAddress;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
@ -26,7 +27,7 @@ public class ConfirmOrderDTO implements Serializable {
|
||||
private Integer combinationId = 0;
|
||||
|
||||
//优惠券减
|
||||
private Boolean deduction = true;
|
||||
private Boolean deduction = false;
|
||||
|
||||
//积分抵扣
|
||||
private Integer integralRatio = 0;
|
||||
@ -43,7 +44,7 @@ public class ConfirmOrderDTO implements Serializable {
|
||||
//店铺信息
|
||||
private List systemStore;
|
||||
|
||||
private String usableCoupon;
|
||||
private YxStoreCouponUser usableCoupon;
|
||||
|
||||
private YxUserQueryVo userInfo;
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/products/**").anonymous()
|
||||
.antMatchers("/product/hot").anonymous()
|
||||
.antMatchers("/category").anonymous()
|
||||
.antMatchers("/coupons/**").anonymous()
|
||||
//.antMatchers("/coupons/**").anonymous()
|
||||
.antMatchers("/image_base64").anonymous()
|
||||
.antMatchers("/register/verify").anonymous()
|
||||
.antMatchers("/register").anonymous()
|
||||
@ -111,6 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/wechat/auth").anonymous()
|
||||
.antMatchers("/share").anonymous()
|
||||
.antMatchers("/wechat/notify").anonymous()
|
||||
.antMatchers("/wechat/serve").anonymous()
|
||||
// 支付宝回调
|
||||
.antMatchers("/api/aliPay/return").anonymous()
|
||||
.antMatchers("/api/aliPay/notify").anonymous()
|
||||
|
||||
@ -82,6 +82,14 @@ public class AuthenticationController extends BaseController {
|
||||
throw new AccountExpiredException("账号已停用,请联系管理员");
|
||||
}
|
||||
|
||||
//设置推广关系
|
||||
if(StrUtil.isNotEmpty(authorizationUser.getSpread()) &&
|
||||
!authorizationUser.getSpread().equals("NaN")){
|
||||
userService.setSpread(Integer.valueOf(authorizationUser.getSpread()),
|
||||
jwtUser.getId().intValue());
|
||||
}
|
||||
|
||||
|
||||
// 生成令牌
|
||||
final String token = jwtTokenUtil.generateToken(jwtUser);
|
||||
|
||||
|
||||
@ -23,6 +23,8 @@ public class AuthorizationUser {
|
||||
|
||||
private String uuid = "";
|
||||
|
||||
private String spread;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{username=" + account + ", password= ******}";
|
||||
|
||||
@ -30,7 +30,7 @@ public class JwtUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username){
|
||||
|
||||
System.out.println("username:"+username);
|
||||
YxUser user = yxUserService.findByName(username);
|
||||
if (user == null) {
|
||||
throw new BadRequestException("账号不存在");
|
||||
|
||||
@ -18,67 +18,69 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxArticle对象", description="文章管理表")
|
||||
@ApiModel(value = "YxArticle对象", description = "文章管理表")
|
||||
public class YxArticle extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "文章管理ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "文章管理ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cid;
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cid;
|
||||
|
||||
@ApiModelProperty(value = "文章标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "文章标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "文章作者")
|
||||
private String author;
|
||||
@ApiModelProperty(value = "文章作者")
|
||||
private String author;
|
||||
|
||||
@ApiModelProperty(value = "文章图片")
|
||||
private String imageInput;
|
||||
@ApiModelProperty(value = "文章图片")
|
||||
private String imageInput;
|
||||
|
||||
@ApiModelProperty(value = "文章简介")
|
||||
private String synopsis;
|
||||
@ApiModelProperty(value = "文章简介")
|
||||
private String synopsis;
|
||||
|
||||
@ApiModelProperty(value = "文章分享标题")
|
||||
private String shareTitle;
|
||||
@ApiModelProperty(value = "文章分享标题")
|
||||
private String shareTitle;
|
||||
|
||||
@ApiModelProperty(value = "文章分享简介")
|
||||
private String shareSynopsis;
|
||||
@ApiModelProperty(value = "文章分享简介")
|
||||
private String shareSynopsis;
|
||||
|
||||
@ApiModelProperty(value = "浏览次数")
|
||||
private String visit;
|
||||
@ApiModelProperty(value = "浏览次数")
|
||||
private String visit;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "原文链接")
|
||||
private String url;
|
||||
@ApiModelProperty(value = "原文链接")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Boolean status;
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否隐藏")
|
||||
private Boolean hide;
|
||||
@ApiModelProperty(value = "是否隐藏")
|
||||
private Boolean hide;
|
||||
|
||||
@ApiModelProperty(value = "管理员id")
|
||||
private Integer adminId;
|
||||
@ApiModelProperty(value = "管理员id")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "产品关联id")
|
||||
private Integer productId;
|
||||
@ApiModelProperty(value = "产品关联id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "是否热门(小程序)")
|
||||
private Boolean isHot;
|
||||
@ApiModelProperty(value = "是否热门(小程序)")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否轮播图(小程序)")
|
||||
private Boolean isBanner;
|
||||
@ApiModelProperty(value = "是否轮播图(小程序)")
|
||||
private Integer isBanner;
|
||||
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
||||
@ -20,21 +20,21 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStoreCouponIssueUser对象", description="优惠券前台用户领取记录表")
|
||||
@ApiModel(value = "YxStoreCouponIssueUser对象", description = "优惠券前台用户领取记录表")
|
||||
public class YxStoreCouponIssueUser extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "领取优惠券用户ID")
|
||||
private Integer uid;
|
||||
@ApiModelProperty(value = "领取优惠券用户ID")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券前台领取ID")
|
||||
private Integer issueCouponId;
|
||||
@ApiModelProperty(value = "优惠券前台领取ID")
|
||||
private Integer issueCouponId;
|
||||
|
||||
@ApiModelProperty(value = "领取时间")
|
||||
private Integer addTime;
|
||||
@ApiModelProperty(value = "领取时间")
|
||||
private Integer addTime;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package co.yixiang.modules.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@ -21,46 +22,46 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxStoreCouponUser对象", description="优惠券发放记录表")
|
||||
@ApiModel(value = "YxStoreCouponUser对象", description = "优惠券发放记录表")
|
||||
public class YxStoreCouponUser extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "优惠券发放记录id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "优惠券发放记录id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "兑换的项目id")
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "兑换的项目id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券所属用户")
|
||||
private Integer uid;
|
||||
@ApiModelProperty(value = "优惠券所属用户")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券名称")
|
||||
private String couponTitle;
|
||||
@ApiModelProperty(value = "优惠券名称")
|
||||
private String couponTitle;
|
||||
|
||||
@ApiModelProperty(value = "优惠券的面值")
|
||||
private BigDecimal couponPrice;
|
||||
@ApiModelProperty(value = "优惠券的面值")
|
||||
private BigDecimal couponPrice;
|
||||
|
||||
@ApiModelProperty(value = "最低消费多少金额可用优惠券")
|
||||
private BigDecimal useMinPrice;
|
||||
@ApiModelProperty(value = "最低消费多少金额可用优惠券")
|
||||
private BigDecimal useMinPrice;
|
||||
|
||||
@ApiModelProperty(value = "优惠券创建时间")
|
||||
private Integer addTime;
|
||||
@ApiModelProperty(value = "优惠券创建时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "优惠券结束时间")
|
||||
private Integer endTime;
|
||||
@ApiModelProperty(value = "优惠券结束时间")
|
||||
private Integer endTime;
|
||||
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Integer useTime;
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Integer useTime;
|
||||
|
||||
@ApiModelProperty(value = "获取方式")
|
||||
private String type;
|
||||
@ApiModelProperty(value = "获取方式")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)")
|
||||
private Boolean status;
|
||||
@ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
private Boolean isFail;
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
private Integer isFail;
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.shop.mapper;
|
||||
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreProductRelationQueryVo;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@ -7,9 +8,12 @@ import co.yixiang.modules.shop.entity.YxStoreCouponIssue;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreCouponIssueQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponIssueQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -22,6 +26,36 @@ import java.io.Serializable;
|
||||
@Repository
|
||||
public interface YxStoreCouponIssueMapper extends BaseMapper<YxStoreCouponIssue> {
|
||||
|
||||
@Select("select A.cid,A.end_time as endTime,A.start_time as startTime," +
|
||||
"A.is_permanent as isPermanent,A.remain_count as remainCount," +
|
||||
"A.total_count as totalCount,A.id,B.coupon_price as couponPrice," +
|
||||
"B.use_min_price as useMinPrice" +
|
||||
" from yx_store_coupon_issue A left join yx_store_coupon B " +
|
||||
"on A.cid = B.id " +
|
||||
"where A.status =1 " +
|
||||
"AND ( ( A.start_time < unix_timestamp(now()) AND A.end_time > unix_timestamp(now()) ) " +
|
||||
"OR ( A.start_time = 0 AND A.end_time = 0 ) )" +
|
||||
" AND A.is_del = 0 AND " +
|
||||
"( A.remain_count > 0 OR A.is_permanent = 1 ) ORDER BY B.sort DESC")
|
||||
List<YxStoreCouponIssueQueryVo> selectList(Page page);
|
||||
|
||||
@Select("select A.cid,A.end_time as endTime,A.start_time as startTime," +
|
||||
"A.is_permanent as isPermanent,A.remain_count as remainCount," +
|
||||
"A.total_count as totalCount,A.id" +
|
||||
" from yx_store_coupon_issue A" +
|
||||
" where A.status =1 and A.id=#{id}" +
|
||||
" AND ( ( A.start_time < unix_timestamp(now()) AND A.end_time > unix_timestamp(now()) ) " +
|
||||
"OR ( A.start_time = 0 AND A.end_time = 0 ) )" +
|
||||
" AND A.is_del = 0 AND " +
|
||||
"( A.remain_count > 0 OR A.is_permanent = 1 )")
|
||||
YxStoreCouponIssueQueryVo selectOne(int id);
|
||||
|
||||
@Update("update yx_store_coupon_issue set remain_count=remain_count-1" +
|
||||
" where id=#{id}")
|
||||
int decCount(@Param("id") int id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -28,6 +28,11 @@ public interface YxStoreProductAttrValueMapper extends BaseMapper<YxStoreProduct
|
||||
int decStockIncSales(@Param("num") int num,@Param("productId") int productId,
|
||||
@Param("unique") String unique);
|
||||
|
||||
@Update("update yx_store_product_attr_value set stock=stock+#{num}, sales=sales-#{num}" +
|
||||
" where product_id=#{productId} and `unique`=#{unique}")
|
||||
int incStockDecSales(@Param("num") int num,@Param("productId") int productId,
|
||||
@Param("unique") String unique);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -24,13 +24,21 @@ import java.io.Serializable;
|
||||
public interface YxStoreProductMapper extends BaseMapper<YxStoreProduct> {
|
||||
|
||||
@Update("update yx_store_product set stock=stock-#{num}, sales=sales+#{num}" +
|
||||
" where product_id=#{productId}")
|
||||
" where id=#{productId}")
|
||||
int decStockIncSales(@Param("num") int num,@Param("productId") int productId);
|
||||
|
||||
@Update("update yx_store_product set stock=stock+#{num}, sales=sales-#{num}" +
|
||||
" where id=#{productId}")
|
||||
int incStockDecSales(@Param("num") int num,@Param("productId") int productId);
|
||||
|
||||
@Update("update yx_store_product set sales=sales+#{num}" +
|
||||
" where id=#{productId}")
|
||||
int incSales(@Param("num") int num,@Param("productId") int productId);
|
||||
|
||||
@Update("update yx_store_product set sales=sales-#{num}" +
|
||||
" where id=#{productId}")
|
||||
int decSales(@Param("num") int num,@Param("productId") int productId);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.shop.mapping;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponUser;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponUserQueryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-26
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface CouponMap extends EntityMapper<YxStoreCouponUserQueryVo, YxStoreCouponUser> {
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -19,6 +20,10 @@ import java.util.Map;
|
||||
*/
|
||||
public interface YxStoreCartService extends BaseService<YxStoreCart> {
|
||||
|
||||
void removeUserCart(int uid, List<String> ids);
|
||||
|
||||
void changeUserCartNum(int cartId,int cartNum,int uid);
|
||||
|
||||
Map<String,Object> getUserProductCartList(int uid,String cartIds,int status);
|
||||
|
||||
int getUserCartNum(int uid,String type,int numType);
|
||||
|
||||
@ -7,6 +7,7 @@ import co.yixiang.modules.shop.web.vo.YxStoreCouponIssueQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -18,6 +19,12 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface YxStoreCouponIssueService extends BaseService<YxStoreCouponIssue> {
|
||||
|
||||
int couponCount(int id,int uid);
|
||||
|
||||
void issueUserCoupon(int id,int uid);
|
||||
|
||||
List<YxStoreCouponIssueQueryVo> getCouponList(int page, int limit, int uid);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -18,6 +18,9 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface YxStoreCouponIssueUserService extends BaseService<YxStoreCouponIssueUser> {
|
||||
|
||||
|
||||
void addUserIssue(int uid,int id);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -23,7 +23,7 @@ public interface YxStoreCouponService extends BaseService<YxStoreCoupon> {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxStoreCouponQueryVo getYxStoreCouponById(Serializable id) throws Exception;
|
||||
YxStoreCouponQueryVo getYxStoreCouponById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
|
||||
@ -7,6 +7,7 @@ import co.yixiang.modules.shop.web.vo.YxStoreCouponUserQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -18,6 +19,20 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface YxStoreCouponUserService extends BaseService<YxStoreCouponUser> {
|
||||
|
||||
void useCoupon(int id);
|
||||
|
||||
YxStoreCouponUser getCoupon(int id,int uid);
|
||||
|
||||
List<YxStoreCouponUser> beUsableCouponList(int uid,double price);
|
||||
|
||||
YxStoreCouponUser beUsableCoupon(int uid,double price);
|
||||
|
||||
void checkInvalidCoupon(int uid);
|
||||
|
||||
List<YxStoreCouponUserQueryVo > getUserCoupon(int uid,int type);
|
||||
|
||||
void addUserCoupon(int uid,int cid);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -20,6 +20,8 @@ import java.util.Map;
|
||||
*/
|
||||
public interface YxStoreProductAttrService extends BaseService<YxStoreProductAttr> {
|
||||
|
||||
void incProductAttrStock(int num, int productId, String unique);
|
||||
|
||||
void decProductAttrStock(int num, int productId, String unique);
|
||||
|
||||
Map<String,Object> getProductAttrDetail(int productId,int uid,int type);
|
||||
|
||||
@ -20,6 +20,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface YxStoreProductService extends BaseService<YxStoreProduct> {
|
||||
|
||||
void incProductStock(int num,int productId,String unique);
|
||||
|
||||
void decProductStock(int num,int productId,String unique);
|
||||
|
||||
int getProductStock(int productId,String unique);
|
||||
|
||||
@ -63,6 +63,59 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<YxStoreCartMapper, Y
|
||||
@Autowired
|
||||
private CartMap cartMap;
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
* @param uid
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
public void removeUserCart(int uid, List<String> ids) {
|
||||
QueryWrapper<YxStoreCart> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("uid",uid).in("id",ids);
|
||||
|
||||
YxStoreCart storeCart = new YxStoreCart();
|
||||
storeCart.setIsDel(1);
|
||||
|
||||
yxStoreCartMapper.update(storeCart,wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 改购物车数量
|
||||
* @param cartId
|
||||
* @param cartNum
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public void changeUserCartNum(int cartId, int cartNum, int uid) {
|
||||
QueryWrapper<YxStoreCart> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("uid",uid).eq("id",cartId);
|
||||
|
||||
YxStoreCart cart = getOne(wrapper);
|
||||
if(ObjectUtil.isNull(cart)){
|
||||
throw new ErrorRequestException("购物车不存在");
|
||||
}
|
||||
|
||||
if(cartNum <= 0){
|
||||
throw new ErrorRequestException("库存错误");
|
||||
}
|
||||
|
||||
//todo 普通商品库存
|
||||
int stock = productService.getProductStock(cart.getProductId()
|
||||
,cart.getProductAttrUnique());
|
||||
if(stock < cartNum){
|
||||
throw new ErrorRequestException("该产品库存不足"+cartNum);
|
||||
}
|
||||
|
||||
if(cartNum == cart.getCartNum()) return;
|
||||
|
||||
YxStoreCart storeCart = new YxStoreCart();
|
||||
storeCart.setCartNum(cartNum);
|
||||
storeCart.setId(Long.valueOf(cartId));
|
||||
|
||||
yxStoreCartMapper.updateById(storeCart);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车列表
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponIssue;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponIssueUser;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCouponIssueMapper;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCouponIssueUserMapper;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponIssueService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponIssueUserService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreCouponIssueQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponIssueQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -16,6 +23,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,6 +42,75 @@ public class YxStoreCouponIssueServiceImpl extends BaseServiceImpl<YxStoreCoupon
|
||||
@Autowired
|
||||
private YxStoreCouponIssueMapper yxStoreCouponIssueMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponIssueUserMapper storeCouponIssueUserMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponUserService storeCouponUserService;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponIssueUserService storeCouponIssueUserService;
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
* @param id id
|
||||
* @param uid uid
|
||||
*/
|
||||
@Override
|
||||
public void issueUserCoupon(int id, int uid) {
|
||||
YxStoreCouponIssueQueryVo couponIssueQueryVo = yxStoreCouponIssueMapper
|
||||
.selectOne(id);
|
||||
if(ObjectUtil.isNull(couponIssueQueryVo)) throw new ErrorRequestException("领取的优惠劵已领完或已过期");
|
||||
|
||||
int count = couponCount(id,uid);
|
||||
if(count > 0) throw new ErrorRequestException("已领取过该优惠劵");
|
||||
|
||||
if(couponIssueQueryVo.getRemainCount() <= 0 && couponIssueQueryVo.getIsPermanent() == 0){
|
||||
throw new ErrorRequestException("抱歉优惠卷已经领取完了");
|
||||
}
|
||||
|
||||
storeCouponUserService.addUserCoupon(uid,couponIssueQueryVo.getCid());
|
||||
|
||||
storeCouponIssueUserService.addUserIssue(uid,id);
|
||||
|
||||
if(couponIssueQueryVo.getTotalCount() > 0){
|
||||
yxStoreCouponIssueMapper.decCount(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int couponCount(int id, int uid) {
|
||||
QueryWrapper<YxStoreCouponIssueUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("uid",uid).eq("issue_coupon_id",id);
|
||||
int count = storeCouponIssueUserMapper.selectCount(wrapper);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券列表
|
||||
* @param page
|
||||
* @param limit
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStoreCouponIssueQueryVo> getCouponList(int page, int limit, int uid) {
|
||||
Page<YxStoreCouponIssue> pageModel = new Page<>(page, limit);
|
||||
List<YxStoreCouponIssueQueryVo> list = yxStoreCouponIssueMapper
|
||||
.selectList(pageModel);
|
||||
for (YxStoreCouponIssueQueryVo couponIssue : list) {
|
||||
int count = couponCount(couponIssue.getId(),uid);
|
||||
if(count > 0){
|
||||
couponIssue.setIsUse(true);
|
||||
}else{
|
||||
couponIssue.setIsUse(false);
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCouponIssueQueryVo getYxStoreCouponIssueById(Serializable id) throws Exception{
|
||||
return yxStoreCouponIssueMapper.getYxStoreCouponIssueById(id);
|
||||
|
||||
@ -7,6 +7,7 @@ import co.yixiang.modules.shop.web.param.YxStoreCouponIssueUserQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponIssueUserQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -34,6 +35,16 @@ public class YxStoreCouponIssueUserServiceImpl extends BaseServiceImpl<YxStoreCo
|
||||
@Autowired
|
||||
private YxStoreCouponIssueUserMapper yxStoreCouponIssueUserMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void addUserIssue(int uid, int id) {
|
||||
YxStoreCouponIssueUser couponIssueUser = new YxStoreCouponIssueUser();
|
||||
couponIssueUser.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
couponIssueUser.setIssueCouponId(id);
|
||||
couponIssueUser.setUid(uid);
|
||||
save(couponIssueUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCouponIssueUserQueryVo getYxStoreCouponIssueUserById(Serializable id) throws Exception{
|
||||
return yxStoreCouponIssueUserMapper.getYxStoreCouponIssueUserById(id);
|
||||
|
||||
@ -35,7 +35,7 @@ public class YxStoreCouponServiceImpl extends BaseServiceImpl<YxStoreCouponMappe
|
||||
private YxStoreCouponMapper yxStoreCouponMapper;
|
||||
|
||||
@Override
|
||||
public YxStoreCouponQueryVo getYxStoreCouponById(Serializable id) throws Exception{
|
||||
public YxStoreCouponQueryVo getYxStoreCouponById(Serializable id){
|
||||
return yxStoreCouponMapper.getYxStoreCouponById(id);
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
package co.yixiang.modules.shop.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCouponUser;
|
||||
import co.yixiang.modules.shop.mapper.YxStoreCouponUserMapper;
|
||||
import co.yixiang.modules.shop.mapping.CouponMap;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreCouponUserQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponQueryVo;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponUserQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -16,6 +23,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,6 +43,141 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl<YxStoreCouponU
|
||||
@Autowired
|
||||
private YxStoreCouponUserMapper yxStoreCouponUserMapper;
|
||||
|
||||
@Autowired
|
||||
private YxStoreCouponService storeCouponService;
|
||||
|
||||
@Autowired
|
||||
private CouponMap couponMap;
|
||||
|
||||
|
||||
@Override
|
||||
public List<YxStoreCouponUser> beUsableCouponList(int uid, double price) {
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("is_fail",0).eq("status",0).le("use_min_price",price).eq("uid",uid);
|
||||
return yxStoreCouponUserMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可用优惠券
|
||||
* @param uid
|
||||
* @param price
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public YxStoreCouponUser beUsableCoupon(int uid, double price) {
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("is_fail",0).eq("status",0).eq("uid",uid)
|
||||
.le("use_min_price",price).last("limit 1") ;
|
||||
return getOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCouponUser getCoupon(int id, int uid) {
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("is_fail",0).eq("status",0).eq("uid",uid)
|
||||
.eq("id",id) ;
|
||||
return getOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useCoupon(int id) {
|
||||
YxStoreCouponUser couponUser = new YxStoreCouponUser();
|
||||
couponUser.setId(id);
|
||||
couponUser.setStatus(1);
|
||||
couponUser.setUseTime(OrderUtil.getSecondTimestampTwo());
|
||||
yxStoreCouponUserMapper.updateById(couponUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查优惠券状态
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public void checkInvalidCoupon(int uid) {
|
||||
int nowTime = OrderUtil.getSecondTimestampTwo();
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.lt("end_time",nowTime).eq("status",0);
|
||||
YxStoreCouponUser couponUser = new YxStoreCouponUser();
|
||||
couponUser.setStatus(2);
|
||||
yxStoreCouponUserMapper.update(couponUser,wrapper);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户优惠券
|
||||
* @param uid uid
|
||||
* @param type type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<YxStoreCouponUserQueryVo> getUserCoupon(int uid, int type) {
|
||||
|
||||
checkInvalidCoupon(uid);
|
||||
QueryWrapper<YxStoreCouponUser> wrapper= new QueryWrapper<>();
|
||||
wrapper.eq("uid",uid);//默认获取所有
|
||||
if(type == 1){//获取用户优惠券(未使用)
|
||||
wrapper.eq("status",0);
|
||||
}else if(type == 2){//获取用户优惠券(已使用)
|
||||
wrapper.eq("status",1);
|
||||
}else if(type > 2){//获取用户优惠券(已过期)
|
||||
wrapper.eq("status",2);
|
||||
}
|
||||
List<YxStoreCouponUser> storeCouponUsers = yxStoreCouponUserMapper.selectList(wrapper);
|
||||
|
||||
List<YxStoreCouponUserQueryVo> storeCouponUserQueryVoList = new ArrayList<>();
|
||||
int nowTime = OrderUtil.getSecondTimestampTwo();
|
||||
for (YxStoreCouponUser couponUser : storeCouponUsers) {
|
||||
YxStoreCouponUserQueryVo queryVo = couponMap.toDto(couponUser);
|
||||
if(couponUser.getIsFail() == 1){
|
||||
queryVo.set_type(0);
|
||||
queryVo.set_msg("已失效");
|
||||
}else if (couponUser.getStatus() == 1){
|
||||
queryVo.set_type(0);
|
||||
queryVo.set_msg("已使用");
|
||||
}else if (couponUser.getStatus() == 2){
|
||||
queryVo.set_type(0);
|
||||
queryVo.set_msg("已过期");
|
||||
}else if(couponUser.getAddTime() > nowTime || couponUser.getEndTime() < nowTime){
|
||||
queryVo.set_type(0);
|
||||
queryVo.set_msg("已过期");
|
||||
}else{
|
||||
if(couponUser.getAddTime()+ 3600*24 > nowTime){
|
||||
queryVo.set_type(2);
|
||||
queryVo.set_msg("可使用");
|
||||
}else{
|
||||
queryVo.set_type(1);
|
||||
queryVo.set_msg("可使用");
|
||||
}
|
||||
}
|
||||
|
||||
storeCouponUserQueryVoList.add(queryVo);
|
||||
|
||||
}
|
||||
return storeCouponUserQueryVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserCoupon(int uid, int cid) {
|
||||
YxStoreCouponQueryVo storeCouponQueryVo = storeCouponService.
|
||||
getYxStoreCouponById(cid);
|
||||
if(ObjectUtil.isNull(storeCouponQueryVo)) throw new ErrorRequestException("优惠劵不存在");
|
||||
|
||||
YxStoreCouponUser couponUser = new YxStoreCouponUser();
|
||||
couponUser.setCid(cid);
|
||||
couponUser.setUid(uid);
|
||||
couponUser.setCouponTitle(storeCouponQueryVo.getTitle());
|
||||
couponUser.setCouponPrice(storeCouponQueryVo.getCouponPrice());
|
||||
couponUser.setUseMinPrice(storeCouponQueryVo.getUseMinPrice());
|
||||
int addTime = OrderUtil.getSecondTimestampTwo();
|
||||
couponUser.setAddTime(addTime);
|
||||
int endTime = addTime + storeCouponQueryVo.getCouponTime() * 86400;
|
||||
couponUser.setEndTime(endTime);
|
||||
couponUser.setType("get");
|
||||
|
||||
save(couponUser);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreCouponUserQueryVo getYxStoreCouponUserById(Serializable id) throws Exception{
|
||||
return yxStoreCouponUserMapper.getYxStoreCouponUserById(id);
|
||||
|
||||
@ -49,6 +49,10 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<YxStoreProduc
|
||||
@Autowired
|
||||
private ProductAttrMap productAttrMap;
|
||||
|
||||
@Override
|
||||
public void incProductAttrStock(int num, int productId, String unique) {
|
||||
yxStoreProductAttrValueMapper.incStockDecSales(num,productId,unique);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decProductAttrStock(int num, int productId, String unique) {
|
||||
|
||||
@ -60,6 +60,22 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<YxStoreProductMap
|
||||
@Autowired
|
||||
private YxStoreProductReplyService replyService;
|
||||
|
||||
/**
|
||||
* 增加库存 减少销量
|
||||
* @param num
|
||||
* @param productId
|
||||
* @param unique
|
||||
*/
|
||||
@Override
|
||||
public void incProductStock(int num, int productId, String unique) {
|
||||
if(StrUtil.isNotEmpty(unique)){
|
||||
storeProductAttrService.incProductAttrStock(num,productId,unique);
|
||||
yxStoreProductMapper.decSales(num,productId);
|
||||
}else{
|
||||
yxStoreProductMapper.incStockDecSales(num,productId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存与销量
|
||||
* @param num
|
||||
|
||||
@ -1,13 +1,21 @@
|
||||
package co.yixiang.modules.shop.web.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.service.YxArticleService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponIssueService;
|
||||
import co.yixiang.modules.shop.service.YxStoreCouponUserService;
|
||||
import co.yixiang.modules.shop.web.param.YxArticleQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxArticleQueryVo;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCouponUserQueryVo;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -26,25 +34,77 @@ import java.util.List;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "优惠券", tags = "优惠券", description = "优惠券")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class CouponController extends BaseController {
|
||||
|
||||
|
||||
|
||||
|
||||
private final YxStoreCouponIssueService couponIssueService;
|
||||
private final YxStoreCouponUserService storeCouponUserService;
|
||||
|
||||
/**
|
||||
* 优惠券列表
|
||||
* 可领取优惠券列表
|
||||
*/
|
||||
@GetMapping("/coupons")
|
||||
@ApiOperation(value = "优惠券列表",notes = "优惠券列表",response = YxArticleQueryVo.class)
|
||||
public ApiResult<List> getList(
|
||||
@ApiOperation(value = "可领取优惠券列表",notes = "可领取优惠券列表")
|
||||
public ApiResult<Object> getList(
|
||||
@RequestParam(value = "page",defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit",defaultValue = "10") int limit
|
||||
){
|
||||
// todo
|
||||
List list = new ArrayList();
|
||||
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(couponIssueService.getCouponList(page,limit,uid));
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
*/
|
||||
@PostMapping("/coupon/receive")
|
||||
@ApiOperation(value = "领取优惠券",notes = "领取优惠券")
|
||||
public ApiResult<Object> receive(@RequestBody String jsonStr){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
if(ObjectUtil.isNull(jsonObject.get("couponId"))){
|
||||
ApiResult.fail("参数错误");
|
||||
}
|
||||
couponIssueService.issueUserCoupon(
|
||||
Integer.valueOf(jsonObject.get("couponId").toString()),uid);
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户已领取优惠券
|
||||
*/
|
||||
@GetMapping("/coupons/user/{type}")
|
||||
@ApiOperation(value = "用户已领取优惠券",notes = "用户已领取优惠券")
|
||||
public ApiResult<Object> getUserList(@PathVariable Integer type){
|
||||
if(ObjectUtil.isEmpty(type)) type = 0;
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
List<YxStoreCouponUserQueryVo> list = null;
|
||||
switch (type){
|
||||
case 0:
|
||||
list = storeCouponUserService.getUserCoupon(uid,0);
|
||||
break;
|
||||
case 1:
|
||||
list = storeCouponUserService.getUserCoupon(uid,1);
|
||||
break;
|
||||
case 2:
|
||||
list = storeCouponUserService.getUserCoupon(uid,2);
|
||||
break;
|
||||
default:
|
||||
list = storeCouponUserService.getUserCoupon(uid,3);
|
||||
}
|
||||
return ApiResult.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券 订单获取
|
||||
*/
|
||||
@GetMapping("/coupons/order/{price}")
|
||||
@ApiOperation(value = "优惠券订单获取",notes = "优惠券订单获取")
|
||||
public ApiResult<Object> orderCoupon(@PathVariable Double price){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(storeCouponUserService.beUsableCouponList(uid,price));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -88,19 +88,10 @@ public class IndexController {
|
||||
@ApiOperation(value = "获取图片base64",notes = "获取图片base64")
|
||||
public ApiResult<List<String>> imageBase64(){
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
return ApiResult.ok(map);
|
||||
//Map<String,Object> map = new LinkedHashMap<>();
|
||||
return ApiResult.ok(null);
|
||||
}
|
||||
|
||||
@GetMapping("/share")
|
||||
@ApiOperation(value = "分享参数",notes = "分享参数")
|
||||
public ApiResult<Object> share(){
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("img","");
|
||||
map.put("title","");
|
||||
map.put("synopsis","");
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,25 +1,31 @@
|
||||
package co.yixiang.modules.shop.web.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.entity.YxStoreCart;
|
||||
import co.yixiang.modules.shop.service.YxStoreCartService;
|
||||
import co.yixiang.modules.shop.web.param.CartIdsParm;
|
||||
import co.yixiang.modules.shop.web.param.YxStoreCartQueryParam;
|
||||
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -86,6 +92,38 @@ public class StoreCartController extends BaseController {
|
||||
return ApiResult.ok(storeCartService.getUserProductCartList(uid,"",0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改产品数量
|
||||
*/
|
||||
@PostMapping("/cart/num")
|
||||
@ApiOperation(value = "修改产品数量",notes = "修改产品数量")
|
||||
public ApiResult<Object> cartNum(@RequestBody String jsonStr){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
if(ObjectUtil.isNull(jsonObject.get("id")) || ObjectUtil.isNull(jsonObject.get("number"))){
|
||||
ApiResult.fail("参数错误");
|
||||
}
|
||||
storeCartService.changeUserCartNum(jsonObject.getInteger("id"),
|
||||
jsonObject.getInteger("number"),uid);
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车删除产品
|
||||
*/
|
||||
@PostMapping("/cart/del")
|
||||
@ApiOperation(value = "购物车删除产品",notes = "购物车删除产品")
|
||||
public ApiResult<Object> cartDel(@Validated @RequestBody CartIdsParm parm){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
// JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
// if(ObjectUtil.isNull(jsonObject.get("ids"))){
|
||||
// ApiResult.fail("参数错误");
|
||||
// }
|
||||
storeCartService.removeUserCart(uid, parm.getIds());
|
||||
|
||||
return ApiResult.ok("ok");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package co.yixiang.modules.shop.web.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName CartIds
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/15
|
||||
**/
|
||||
@Data
|
||||
public class CartIdsParm {
|
||||
List<String> ids;
|
||||
}
|
||||
@ -3,6 +3,7 @@ package co.yixiang.modules.shop.web.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
@ -16,65 +17,67 @@ import java.util.Date;
|
||||
* @date 2019-10-02
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxArticleQueryVo对象", description="文章管理表查询参数")
|
||||
public class YxArticleQueryVo implements Serializable{
|
||||
@ApiModel(value = "YxArticleQueryVo对象", description = "文章管理表查询参数")
|
||||
public class YxArticleQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "文章管理ID")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "文章管理ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cid;
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cid;
|
||||
|
||||
@ApiModelProperty(value = "文章标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "文章标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "文章作者")
|
||||
private String author;
|
||||
@ApiModelProperty(value = "文章作者")
|
||||
private String author;
|
||||
|
||||
@ApiModelProperty(value = "文章图片")
|
||||
private String imageInput;
|
||||
@ApiModelProperty(value = "文章图片")
|
||||
private String imageInput;
|
||||
|
||||
@ApiModelProperty(value = "文章简介")
|
||||
private String synopsis;
|
||||
@ApiModelProperty(value = "文章简介")
|
||||
private String synopsis;
|
||||
|
||||
@ApiModelProperty(value = "文章分享标题")
|
||||
private String shareTitle;
|
||||
@ApiModelProperty(value = "文章分享标题")
|
||||
private String shareTitle;
|
||||
|
||||
@ApiModelProperty(value = "文章分享简介")
|
||||
private String shareSynopsis;
|
||||
@ApiModelProperty(value = "文章分享简介")
|
||||
private String shareSynopsis;
|
||||
|
||||
@ApiModelProperty(value = "浏览次数")
|
||||
private String visit;
|
||||
@ApiModelProperty(value = "浏览次数")
|
||||
private String visit;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "原文链接")
|
||||
private String url;
|
||||
@ApiModelProperty(value = "原文链接")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Boolean status;
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Boolean status;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private String addTime;
|
||||
|
||||
@ApiModelProperty(value = "是否隐藏")
|
||||
private Boolean hide;
|
||||
@ApiModelProperty(value = "是否隐藏")
|
||||
private Boolean hide;
|
||||
|
||||
@ApiModelProperty(value = "管理员id")
|
||||
private Integer adminId;
|
||||
@ApiModelProperty(value = "管理员id")
|
||||
private Integer adminId;
|
||||
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
@ApiModelProperty(value = "商户id")
|
||||
private Integer merId;
|
||||
|
||||
@ApiModelProperty(value = "产品关联id")
|
||||
private Integer productId;
|
||||
@ApiModelProperty(value = "产品关联id")
|
||||
private Integer productId;
|
||||
|
||||
@ApiModelProperty(value = "是否热门(小程序)")
|
||||
private Boolean isHot;
|
||||
@ApiModelProperty(value = "是否热门(小程序)")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "是否轮播图(小程序)")
|
||||
private Boolean isBanner;
|
||||
@ApiModelProperty(value = "是否轮播图(小程序)")
|
||||
private Integer isBanner;
|
||||
|
||||
private String content;
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package co.yixiang.modules.shop.web.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
@ -16,36 +17,37 @@ import java.util.Date;
|
||||
* @date 2019-10-27
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxStoreCouponIssueQueryVo对象", description="优惠券前台领取表查询参数")
|
||||
public class YxStoreCouponIssueQueryVo implements Serializable{
|
||||
@ApiModel(value = "YxStoreCouponIssueQueryVo对象", description = "优惠券前台领取表查询参数")
|
||||
public class YxStoreCouponIssueQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "优惠券ID")
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "优惠券ID")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券领取开启时间")
|
||||
private Integer startTime;
|
||||
@ApiModelProperty(value = "优惠券领取开启时间")
|
||||
private Integer startTime;
|
||||
|
||||
@ApiModelProperty(value = "优惠券领取结束时间")
|
||||
private Integer endTime;
|
||||
@ApiModelProperty(value = "优惠券领取结束时间")
|
||||
private Integer endTime;
|
||||
|
||||
@ApiModelProperty(value = "优惠券领取数量")
|
||||
private Integer totalCount;
|
||||
@ApiModelProperty(value = "优惠券领取数量")
|
||||
private Integer totalCount;
|
||||
|
||||
@ApiModelProperty(value = "优惠券剩余领取数量")
|
||||
private Integer remainCount;
|
||||
@ApiModelProperty(value = "优惠券剩余领取数量")
|
||||
private Integer remainCount;
|
||||
|
||||
@ApiModelProperty(value = "是否无限张数")
|
||||
private Boolean isPermanent;
|
||||
@ApiModelProperty(value = "是否无限张数")
|
||||
private Integer isPermanent;
|
||||
|
||||
@ApiModelProperty(value = "1 正常 0 未开启 -1 已无效")
|
||||
private Boolean status;
|
||||
@ApiModelProperty(value = "1 正常 0 未开启 -1 已无效")
|
||||
private Integer status;
|
||||
|
||||
private Boolean isDel;
|
||||
private Double couponPrice;
|
||||
|
||||
@ApiModelProperty(value = "优惠券添加时间")
|
||||
private Integer addTime;
|
||||
private Double useMinPrice;
|
||||
|
||||
private Boolean isUse;
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package co.yixiang.modules.shop.web.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -17,44 +18,48 @@ import java.util.Date;
|
||||
* @date 2019-10-27
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxStoreCouponUserQueryVo对象", description="优惠券发放记录表查询参数")
|
||||
public class YxStoreCouponUserQueryVo implements Serializable{
|
||||
@ApiModel(value = "YxStoreCouponUserQueryVo对象", description = "优惠券发放记录表查询参数")
|
||||
public class YxStoreCouponUserQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "优惠券发放记录id")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "优惠券发放记录id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "兑换的项目id")
|
||||
private Integer cid;
|
||||
@ApiModelProperty(value = "兑换的项目id")
|
||||
private Integer cid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券所属用户")
|
||||
private Integer uid;
|
||||
@ApiModelProperty(value = "优惠券所属用户")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "优惠券名称")
|
||||
private String couponTitle;
|
||||
@ApiModelProperty(value = "优惠券名称")
|
||||
private String couponTitle;
|
||||
|
||||
@ApiModelProperty(value = "优惠券的面值")
|
||||
private BigDecimal couponPrice;
|
||||
@ApiModelProperty(value = "优惠券的面值")
|
||||
private BigDecimal couponPrice;
|
||||
|
||||
@ApiModelProperty(value = "最低消费多少金额可用优惠券")
|
||||
private BigDecimal useMinPrice;
|
||||
@ApiModelProperty(value = "最低消费多少金额可用优惠券")
|
||||
private BigDecimal useMinPrice;
|
||||
|
||||
@ApiModelProperty(value = "优惠券创建时间")
|
||||
private Integer addTime;
|
||||
@ApiModelProperty(value = "优惠券创建时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "优惠券结束时间")
|
||||
private Integer endTime;
|
||||
@ApiModelProperty(value = "优惠券结束时间")
|
||||
private Integer endTime;
|
||||
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Integer useTime;
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
private Integer useTime;
|
||||
|
||||
@ApiModelProperty(value = "获取方式")
|
||||
private String type;
|
||||
@ApiModelProperty(value = "获取方式")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)")
|
||||
private Boolean status;
|
||||
@ApiModelProperty(value = "状态(0:未使用,1:已使用, 2:已过期)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
private Boolean isFail;
|
||||
@ApiModelProperty(value = "是否有效")
|
||||
private Integer isFail;
|
||||
|
||||
private Integer _type;
|
||||
|
||||
private String _msg;
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
//package co.yixiang.modules.task;
|
||||
//
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import co.yixiang.modules.order.entity.YxStoreOrder;
|
||||
//import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
//import co.yixiang.redisson.DelayJob;
|
||||
//import co.yixiang.redisson.ExecuteJob;
|
||||
//import co.yixiang.utils.SpringContextHolder;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class CancelOrderService implements ExecuteJob {
|
||||
// @Override
|
||||
// public void execute(DelayJob job) {
|
||||
// log.info("系统开始处理延时任务---订单超时未付款---" + job.getOrderId());
|
||||
//
|
||||
// YxStoreOrderService yxorderService = SpringContextHolder.getBean(YxStoreOrderService.class);
|
||||
//
|
||||
// YxStoreOrder order = null;
|
||||
// try {
|
||||
// order = yxorderService.getOne(new QueryWrapper<YxStoreOrder>().eq("id", job.getOrderId()).eq("is_del",0));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// if(ObjectUtil.isNull(order)) {
|
||||
// return;
|
||||
// }
|
||||
// if(order.getPaid() != 0){
|
||||
// return;
|
||||
// }
|
||||
// yxorderService.cancelOrderByTask(job.getOrderId());
|
||||
// log.info("系统结束处理延时任务---订单超时未付款取消---" + job.getOrderId());
|
||||
// }
|
||||
//}
|
||||
@ -0,0 +1,58 @@
|
||||
package co.yixiang.modules.user.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "YxSystemAttachment对象", description = "附件管理表")
|
||||
public class YxSystemAttachment extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "att_id", type = IdType.AUTO)
|
||||
private Integer attId;
|
||||
|
||||
@ApiModelProperty(value = "附件名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "附件路径")
|
||||
private String attDir;
|
||||
|
||||
@ApiModelProperty(value = "压缩图片路径")
|
||||
private String sattDir;
|
||||
|
||||
@ApiModelProperty(value = "附件大小")
|
||||
private String attSize;
|
||||
|
||||
@ApiModelProperty(value = "附件类型")
|
||||
private String attType;
|
||||
|
||||
@ApiModelProperty(value = "分类ID0编辑器,1产品图片,2拼团图片,3砍价图片,4秒杀图片,5文章图片,6组合数据图")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "上传时间")
|
||||
private Integer time;
|
||||
|
||||
@ApiModelProperty(value = "图片上传类型 1本地 2七牛云 3OSS 4COS ")
|
||||
private Integer imageType;
|
||||
|
||||
@ApiModelProperty(value = "图片上传模块类型 1 后台上传 2 用户生成")
|
||||
private Integer moduleType;
|
||||
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class YxUser extends BaseEntity {
|
||||
private String userType;
|
||||
|
||||
@ApiModelProperty(value = "是否为推广员")
|
||||
private Boolean isPromoter;
|
||||
private Integer isPromoter;
|
||||
|
||||
@ApiModelProperty(value = "用户购买次数")
|
||||
private Integer payCount;
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package co.yixiang.modules.user.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import co.yixiang.common.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "YxUserExtract对象", description = "用户提现表")
|
||||
public class YxUserExtract extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "bank = 银行卡 alipay = 支付宝wx=微信")
|
||||
private String extractType;
|
||||
|
||||
@ApiModelProperty(value = "银行卡")
|
||||
private String bankCode;
|
||||
|
||||
@ApiModelProperty(value = "开户地址")
|
||||
private String bankAddress;
|
||||
|
||||
@ApiModelProperty(value = "支付宝账号")
|
||||
private String alipayCode;
|
||||
|
||||
@ApiModelProperty(value = "提现金额")
|
||||
private BigDecimal extractPrice;
|
||||
|
||||
private String mark;
|
||||
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty(value = "无效原因")
|
||||
private String failMsg;
|
||||
|
||||
private Integer failTime;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "-1 未通过 0 审核中 1 已提现")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "微信号")
|
||||
private String wechat;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package co.yixiang.modules.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.web.param.YxSystemAttachmentQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxSystemAttachmentQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Repository
|
||||
public interface YxSystemAttachmentMapper extends BaseMapper<YxSystemAttachment> {
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxSystemAttachmentQueryVo getYxSystemAttachmentById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param yxSystemAttachmentQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<YxSystemAttachmentQueryVo> getYxSystemAttachmentPageList(@Param("page") Page page, @Param("param") YxSystemAttachmentQueryParam yxSystemAttachmentQueryParam);
|
||||
|
||||
}
|
||||
@ -1,15 +1,23 @@
|
||||
package co.yixiang.modules.user.mapper;
|
||||
|
||||
import co.yixiang.modules.user.web.dto.BillDTO;
|
||||
import co.yixiang.modules.user.web.dto.BillOrderRecordDTO;
|
||||
import co.yixiang.modules.user.web.dto.PromUserDTO;
|
||||
import co.yixiang.modules.user.web.dto.UserBillDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.web.param.YxUserBillQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserBillQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -22,6 +30,38 @@ import java.io.Serializable;
|
||||
@Repository
|
||||
public interface YxUserBillMapper extends BaseMapper<YxUserBill> {
|
||||
|
||||
@Select("SELECT o.order_id as orderId,FROM_UNIXTIME(b.add_time, '%Y-%m-%d %H:%i') as time," +
|
||||
"b.number,u.avatar,u.nickname FROM yx_user_bill b " +
|
||||
"INNER JOIN yx_store_order o ON o.id=b.link_id " +
|
||||
"RIGHT JOIN yx_user u ON u.uid=o.uid" +
|
||||
" WHERE b.uid = #{uid} AND ( FROM_UNIXTIME(b.add_time, '%Y-%m')= #{time} ) AND " +
|
||||
"b.category = 'now_money' AND b.type = 'brokerage' ORDER BY time DESC")
|
||||
List<BillOrderRecordDTO> getBillOrderRList(@Param("time") String time, @Param("uid") int uid);
|
||||
|
||||
@Select("SELECT FROM_UNIXTIME(add_time,'%Y-%m') as time " +
|
||||
" FROM yx_user_bill ${ew.customSqlSegment}")
|
||||
List<String> getBillOrderList(@Param(Constants.WRAPPER) Wrapper<YxUserBill> userWrapper,Page page);
|
||||
|
||||
@Select("SELECT FROM_UNIXTIME(add_time,'%Y-%m') as time,group_concat(id SEPARATOR ',') ids " +
|
||||
" FROM yx_user_bill ${ew.customSqlSegment}")
|
||||
List<BillDTO> getBillList(@Param(Constants.WRAPPER) Wrapper<YxUserBill> userWrapper,Page page);
|
||||
|
||||
@Select("SELECT FROM_UNIXTIME(add_time,'%Y-%m-%d %H:%i') as add_time,title,number,pm " +
|
||||
" FROM yx_user_bill ${ew.customSqlSegment}")
|
||||
List<UserBillDTO> getUserBillList(@Param(Constants.WRAPPER) Wrapper<YxUserBill> userWrapper);
|
||||
|
||||
@Select("select IFNULL(sum(number),0) from yx_user_bill " +
|
||||
"where status=1 and type='brokerage' and pm=1 and category='now_money' " +
|
||||
"and uid=#{uid}")
|
||||
double sumPrice(@Param("uid") int uid);
|
||||
|
||||
|
||||
@Select("select IFNULL(sum(number),0) from yx_user_bill " +
|
||||
"where status=1 and type='brokerage' and pm=1 and category='now_money' " +
|
||||
"and uid=#{uid} and TO_DAYS(NOW()) - TO_DAYS(add_time) <= 1")
|
||||
double sumYesterdayPrice(@Param("uid") int uid);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package co.yixiang.modules.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import co.yixiang.modules.user.entity.YxUserExtract;
|
||||
import co.yixiang.modules.user.web.param.YxUserExtractQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserExtractQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Repository
|
||||
public interface YxUserExtractMapper extends BaseMapper<YxUserExtract> {
|
||||
|
||||
@Select("select IFNULL(sum(extract_price),0) from yx_user_extract " +
|
||||
"where status=1 " +
|
||||
"and uid=#{uid}")
|
||||
double sumPrice(@Param("uid") int uid);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxUserExtractQueryVo getYxUserExtractById(Serializable id);
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param page
|
||||
* @param yxUserExtractQueryParam
|
||||
* @return
|
||||
*/
|
||||
IPage<YxUserExtractQueryVo> getYxUserExtractPageList(@Param("page") Page page, @Param("param") YxUserExtractQueryParam yxUserExtractQueryParam);
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package co.yixiang.modules.user.mapper;
|
||||
|
||||
import co.yixiang.modules.user.web.dto.PromUserDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@ -7,10 +8,12 @@ import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.web.param.YxUserQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -23,14 +26,44 @@ import java.io.Serializable;
|
||||
@Repository
|
||||
public interface YxUserMapper extends BaseMapper<YxUser> {
|
||||
|
||||
|
||||
|
||||
@Select("<script>SELECT u.uid,u.nickname,u.avatar,from_unixtime(u.add_time,'%Y/%m/%d') as time," +
|
||||
"u.spread_count as childCount,COUNT(o.id) as orderCount," +
|
||||
"IFNULL(SUM(o.pay_price),0) as numberCount FROM yx_user u " +
|
||||
"LEFT JOIN yx_store_order o ON u.uid=o.uid " +
|
||||
"WHERE u.uid in <foreach item='id' index='index' collection='uids' " +
|
||||
" open='(' separator=',' close=')'>" +
|
||||
" #{id}" +
|
||||
" </foreach> <if test='keyword != null'>" +
|
||||
" AND ( u.nickname LIKE CONCAT(CONCAT('%',#{keyword}),'%') OR u.phone LIKE CONCAT(CONCAT('%',#{keyword}),'%'))</if>" +
|
||||
" GROUP BY u.uid ORDER BY #{orderBy} " +
|
||||
"</script>")
|
||||
List<PromUserDTO> getUserSpreadCountList(Page page,
|
||||
@Param("uids") List uids,
|
||||
@Param("keyword") String keyword,
|
||||
@Param("orderBy") String orderBy);
|
||||
|
||||
@Update("update yx_user set now_money=now_money-#{payPrice}" +
|
||||
" where uid=#{uid}")
|
||||
int decPrice(@Param("payPrice") double payPrice,@Param("uid") int uid);
|
||||
|
||||
@Update("update yx_user set brokerage_price=brokerage_price+#{brokeragePrice}" +
|
||||
" where uid=#{uid}")
|
||||
int incBrokeragePrice(@Param("brokeragePrice") double brokeragePrice,@Param("uid") int uid);
|
||||
|
||||
@Update("update yx_user set pay_count=pay_count+1" +
|
||||
" where uid=#{uid}")
|
||||
int incPayCount(@Param("uid") int uid);
|
||||
|
||||
@Update("update yx_user set integral=integral-#{integral}" +
|
||||
" where uid=#{uid}")
|
||||
int decIntegral(@Param("integral") double integral,@Param("uid") int uid);
|
||||
|
||||
@Update("update yx_user set integral=integral+#{integral}" +
|
||||
" where uid=#{uid}")
|
||||
int incIntegral(@Param("integral") double integral,@Param("uid") int uid);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.user.mapping;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.web.vo.YxUserBillQueryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2019-10-26
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface BiillMap extends EntityMapper<YxUserBillQueryVo, YxUserBill> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package co.yixiang.modules.user.service;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.user.web.param.YxSystemAttachmentQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxSystemAttachmentQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
public interface YxSystemAttachmentService extends BaseService<YxSystemAttachment> {
|
||||
|
||||
YxSystemAttachment getInfo(String name);
|
||||
|
||||
void attachmentAdd(String name,String attSize,String attDir,String sattDir);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxSystemAttachmentQueryVo getYxSystemAttachmentById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param yxSystemAttachmentQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<YxSystemAttachmentQueryVo> getYxSystemAttachmentPageList(YxSystemAttachmentQueryParam yxSystemAttachmentQueryParam) throws Exception;
|
||||
|
||||
}
|
||||
@ -2,11 +2,15 @@ package co.yixiang.modules.user.service;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.user.web.dto.BillDTO;
|
||||
import co.yixiang.modules.user.web.param.YxUserBillQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserBillQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -18,6 +22,16 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface YxUserBillService extends BaseService<YxUserBill> {
|
||||
|
||||
Map<String,Object> spreadOrder(int uid,int page,int limit);
|
||||
|
||||
List<BillDTO> getUserBillList(int page, int limit, int uid, int type);
|
||||
|
||||
double getBrokerage(int uid);
|
||||
|
||||
double yesterdayCommissionSum(int uid);
|
||||
|
||||
List<YxUserBillQueryVo> userBillList(int uid, int page, int limit, String category);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package co.yixiang.modules.user.service;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxUserExtract;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.user.web.param.UserExtParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserExtractQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserExtractQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
public interface YxUserExtractService extends BaseService<YxUserExtract> {
|
||||
|
||||
void userExtract(int uid, UserExtParam param);
|
||||
|
||||
double extractSum(int uid);
|
||||
|
||||
/**
|
||||
* 根据ID获取查询对象
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
YxUserExtractQueryVo getYxUserExtractById(Serializable id) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取分页对象
|
||||
* @param yxUserExtractQueryParam
|
||||
* @return
|
||||
*/
|
||||
Paging<YxUserExtractQueryVo> getYxUserExtractPageList(YxUserExtractQueryParam yxUserExtractQueryParam) throws Exception;
|
||||
|
||||
}
|
||||
@ -1,12 +1,17 @@
|
||||
package co.yixiang.modules.user.service;
|
||||
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.modules.user.web.dto.PromUserDTO;
|
||||
import co.yixiang.modules.user.web.dto.UserRankDTO;
|
||||
import co.yixiang.modules.user.web.param.PromParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -18,6 +23,23 @@ import java.io.Serializable;
|
||||
*/
|
||||
public interface YxUserService extends BaseService<YxUser> {
|
||||
|
||||
void incIntegral(int uid,double integral);
|
||||
|
||||
YxUserQueryVo getNewYxUserById(Serializable id);
|
||||
boolean backOrderBrokerage(YxStoreOrderQueryVo order);
|
||||
|
||||
boolean backOrderBrokerageTwo(YxStoreOrderQueryVo order);
|
||||
|
||||
void setUserSpreadCount(int uid);
|
||||
|
||||
int getSpreadCount(int uid,int type);
|
||||
|
||||
List<PromUserDTO> getUserSpreadGrade(PromParam promParam,int uid);
|
||||
|
||||
boolean setSpread(int spread,int uid);
|
||||
|
||||
void decIntegral(int uid,double integral);
|
||||
|
||||
void incPayCount(int uid);
|
||||
|
||||
void decPrice(int uid,double payPrice);
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package co.yixiang.modules.user.service.impl;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.mapper.YxSystemAttachmentMapper;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import co.yixiang.modules.user.web.param.YxSystemAttachmentQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxSystemAttachmentQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class YxSystemAttachmentServiceImpl extends BaseServiceImpl<YxSystemAttachmentMapper, YxSystemAttachment> implements YxSystemAttachmentService {
|
||||
|
||||
@Autowired
|
||||
private YxSystemAttachmentMapper yxSystemAttachmentMapper;
|
||||
|
||||
@Override
|
||||
public YxSystemAttachment getInfo(String name) {
|
||||
QueryWrapper<YxSystemAttachment> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name",name);
|
||||
return yxSystemAttachmentMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attachmentAdd(String name, String attSize, String attDir,String sattDir) {
|
||||
YxSystemAttachment attachment = new YxSystemAttachment();
|
||||
attachment.setName(name);
|
||||
attachment.setAttSize(attSize);
|
||||
attachment.setAttDir(attDir);
|
||||
attachment.setAttType("image/jpeg");
|
||||
attachment.setSattDir(sattDir);
|
||||
attachment.setTime(OrderUtil.getSecondTimestampTwo());
|
||||
attachment.setImageType(1);
|
||||
attachment.setModuleType(2);
|
||||
attachment.setPid(1);
|
||||
yxSystemAttachmentMapper.insert(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxSystemAttachmentQueryVo getYxSystemAttachmentById(Serializable id) throws Exception{
|
||||
return yxSystemAttachmentMapper.getYxSystemAttachmentById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<YxSystemAttachmentQueryVo> getYxSystemAttachmentPageList(YxSystemAttachmentQueryParam yxSystemAttachmentQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxSystemAttachmentQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<YxSystemAttachmentQueryVo> iPage = yxSystemAttachmentMapper.getYxSystemAttachmentPageList(page,yxSystemAttachmentQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,11 +2,16 @@ package co.yixiang.modules.user.service.impl;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.mapper.YxUserBillMapper;
|
||||
import co.yixiang.modules.user.mapping.BiillMap;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.web.dto.BillDTO;
|
||||
import co.yixiang.modules.user.web.dto.BillOrderDTO;
|
||||
import co.yixiang.modules.user.web.dto.BillOrderRecordDTO;
|
||||
import co.yixiang.modules.user.web.param.YxUserBillQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserBillQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -16,6 +21,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,6 +43,100 @@ public class YxUserBillServiceImpl extends BaseServiceImpl<YxUserBillMapper, YxU
|
||||
@Autowired
|
||||
private YxUserBillMapper yxUserBillMapper;
|
||||
|
||||
@Autowired
|
||||
private BiillMap biillMap;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> spreadOrder(int uid, int page, int limit) {
|
||||
QueryWrapper<YxUserBill> wrapper = new QueryWrapper<>();
|
||||
wrapper.in("uid",uid).eq("type","brokerage")
|
||||
.eq("category","now_money").orderByDesc("time")
|
||||
.groupBy("time");
|
||||
Page<YxUserBill> pageModel = new Page<>(page, limit);
|
||||
List<String> list = yxUserBillMapper.getBillOrderList(wrapper,pageModel);
|
||||
|
||||
|
||||
// QueryWrapper<YxUserBill> wrapperT = new QueryWrapper<>();
|
||||
// wrapperT.in("uid",uid).eq("type","brokerage")
|
||||
// .eq("category","now_money");
|
||||
|
||||
int count = (int)pageModel.getTotal();
|
||||
List<BillOrderDTO> listT = new ArrayList<>();
|
||||
for (String str : list) {
|
||||
BillOrderDTO billOrderDTO = new BillOrderDTO();
|
||||
List<BillOrderRecordDTO> orderRecordDTOS = yxUserBillMapper
|
||||
.getBillOrderRList(str,uid);
|
||||
billOrderDTO.setChild(orderRecordDTOS);
|
||||
billOrderDTO.setCount(orderRecordDTOS.size());
|
||||
billOrderDTO.setTime(str);
|
||||
|
||||
listT.add(billOrderDTO);
|
||||
}
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("list",listT);
|
||||
map.put("count",count);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BillDTO> getUserBillList(int page, int limit, int uid, int type) {
|
||||
QueryWrapper<YxUserBill> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("category","now_money").eq("uid",uid).
|
||||
orderByDesc("add_time").groupBy("time");
|
||||
switch (type){
|
||||
case 0:
|
||||
String str = "recharge,brokerage,pay_product,system_add,pay_product_refund,system_sub";
|
||||
wrapper.in("type",str.split(","));
|
||||
break;
|
||||
case 1:
|
||||
wrapper.eq("type","pay_product");
|
||||
break;
|
||||
case 2:
|
||||
wrapper.eq("type","recharge");
|
||||
break;
|
||||
case 3:
|
||||
wrapper.eq("type","brokerage");
|
||||
break;
|
||||
case 4:
|
||||
wrapper.eq("type","extract");
|
||||
break;
|
||||
}
|
||||
Page<YxUserBill> pageModel = new Page<>(page, limit);
|
||||
List<BillDTO> billDTOList = yxUserBillMapper.getBillList(wrapper,pageModel);
|
||||
for (BillDTO billDTO : billDTOList) {
|
||||
QueryWrapper<YxUserBill> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.in("id",billDTO.getIds().split(","));
|
||||
billDTO.setList(yxUserBillMapper.getUserBillList(wrapperT));
|
||||
|
||||
}
|
||||
|
||||
return billDTOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBrokerage(int uid) {
|
||||
return yxUserBillMapper.sumPrice(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double yesterdayCommissionSum(int uid) {
|
||||
return yxUserBillMapper.sumYesterdayPrice(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<YxUserBillQueryVo> userBillList(int uid, int page,
|
||||
int limit, String category) {
|
||||
QueryWrapper<YxUserBill> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("status",1).eq("uid",uid)
|
||||
.eq("category",category).orderByDesc("add_time");
|
||||
Page<YxUserBill> pageModel = new Page<>(page, limit);
|
||||
|
||||
IPage<YxUserBill> pageList = yxUserBillMapper.selectPage(pageModel,wrapper);
|
||||
return biillMap.toDto(pageList.getRecords());
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxUserBillQueryVo getYxUserBillById(Serializable id) throws Exception{
|
||||
return yxUserBillMapper.getYxUserBillById(id);
|
||||
@ -41,7 +144,7 @@ public class YxUserBillServiceImpl extends BaseServiceImpl<YxUserBillMapper, YxU
|
||||
|
||||
@Override
|
||||
public Paging<YxUserBillQueryVo> getYxUserBillPageList(YxUserBillQueryParam yxUserBillQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxUserBillQueryParam,OrderItem.desc("create_time"));
|
||||
Page page = setPageParam(yxUserBillQueryParam,OrderItem.desc("add_time"));
|
||||
IPage<YxUserBillQueryVo> iPage = yxUserBillMapper.getYxUserBillPageList(page,yxUserBillQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
package co.yixiang.modules.user.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.entity.YxUserExtract;
|
||||
import co.yixiang.modules.user.mapper.YxUserExtractMapper;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserExtractService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.param.UserExtParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserExtractQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserExtractQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class YxUserExtractServiceImpl extends BaseServiceImpl<YxUserExtractMapper, YxUserExtract> implements YxUserExtractService {
|
||||
|
||||
@Autowired
|
||||
private YxUserExtractMapper yxUserExtractMapper;
|
||||
|
||||
@Autowired
|
||||
private YxUserService userService;
|
||||
|
||||
@Autowired
|
||||
private YxUserBillService billService;
|
||||
|
||||
/**
|
||||
* 开始提现
|
||||
* @param uid
|
||||
* @param param
|
||||
*/
|
||||
@Override
|
||||
public void userExtract(int uid, UserExtParam param) {
|
||||
YxUserQueryVo userInfo = userService.getYxUserById(uid);
|
||||
double extractPrice = userInfo.getBrokeragePrice().doubleValue();
|
||||
if(extractPrice <= 0) throw new ErrorRequestException("提现佣金不足");
|
||||
|
||||
double money = Double.valueOf(param.getMoney());
|
||||
if(money > extractPrice) throw new ErrorRequestException("提现佣金不足");
|
||||
|
||||
if(money <= 0) throw new ErrorRequestException("提现佣金大于0");
|
||||
|
||||
double balance = NumberUtil.sub(extractPrice,money);
|
||||
if(balance < 0) balance = 0;
|
||||
|
||||
YxUserExtract userExtract = new YxUserExtract();
|
||||
userExtract.setUid(uid);
|
||||
userExtract.setExtractType(param.getExtractType());
|
||||
userExtract.setExtractPrice(new BigDecimal(param.getMoney()));
|
||||
userExtract.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
userExtract.setBalance(BigDecimal.valueOf(balance));
|
||||
userExtract.setStatus(0);
|
||||
|
||||
if(StrUtil.isNotEmpty(param.getName())){
|
||||
userExtract.setRealName(param.getName());
|
||||
}else {
|
||||
userExtract.setRealName(userInfo.getNickname());
|
||||
}
|
||||
|
||||
if(StrUtil.isNotEmpty(param.getWeixin())){
|
||||
userExtract.setWechat(param.getWeixin());
|
||||
}else {
|
||||
userExtract.setWechat(userInfo.getNickname());
|
||||
}
|
||||
|
||||
String mark = "";
|
||||
if(param.getExtractType().equals("alipay")){
|
||||
if(StrUtil.isEmpty(param.getAlipayCode())){
|
||||
throw new ErrorRequestException("请输入支付宝账号");
|
||||
}
|
||||
userExtract.setAlipayCode(param.getAlipayCode());
|
||||
mark = "使用支付宝提现"+param.getMoney()+"元";
|
||||
}else if(param.getExtractType().equals("weixin")){
|
||||
if(StrUtil.isEmpty(param.getWeixin())){
|
||||
throw new ErrorRequestException("请输入微信账号");
|
||||
}
|
||||
|
||||
mark = "使用微信提现"+param.getMoney()+"元";
|
||||
}
|
||||
|
||||
yxUserExtractMapper.insert(userExtract);
|
||||
|
||||
//更新佣金
|
||||
YxUser yxUser = new YxUser();
|
||||
yxUser.setBrokeragePrice(BigDecimal.valueOf(balance));
|
||||
yxUser.setUid(uid);
|
||||
userService.updateById(yxUser);
|
||||
//插入流水
|
||||
YxUserBill userBill = new YxUserBill();
|
||||
userBill.setUid(uid);
|
||||
userBill.setTitle("佣金提现");
|
||||
userBill.setLinkId(userExtract.getId().toString());
|
||||
userBill.setCategory("now_money");
|
||||
userBill.setType("extract");
|
||||
userBill.setNumber(BigDecimal.valueOf(money));
|
||||
userBill.setBalance(BigDecimal.valueOf(balance));
|
||||
userBill.setMark(mark);
|
||||
userBill.setStatus(1);
|
||||
userBill.setPm(0);
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractSum(int uid) {
|
||||
return yxUserExtractMapper.sumPrice(uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxUserExtractQueryVo getYxUserExtractById(Serializable id) throws Exception{
|
||||
return yxUserExtractMapper.getYxUserExtractById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<YxUserExtractQueryVo> getYxUserExtractPageList(YxUserExtractQueryParam yxUserExtractQueryParam) throws Exception{
|
||||
Page page = setPageParam(yxUserExtractQueryParam,OrderItem.desc("create_time"));
|
||||
IPage<YxUserExtractQueryVo> iPage = yxUserExtractMapper.getYxUserExtractPageList(page,yxUserExtractQueryParam);
|
||||
return new Paging(iPage);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,25 @@
|
||||
package co.yixiang.modules.user.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.exception.ErrorRequestException;
|
||||
import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxUserBill;
|
||||
import co.yixiang.modules.user.mapper.YxUserMapper;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.dto.PromUserDTO;
|
||||
import co.yixiang.modules.user.web.dto.UserRankDTO;
|
||||
import co.yixiang.modules.user.web.param.PromParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -18,6 +30,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@ -39,6 +55,306 @@ public class YxUserServiceImpl extends BaseServiceImpl<YxUserMapper, YxUser> imp
|
||||
@Autowired
|
||||
private YxStoreOrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private YxSystemConfigService systemConfigService;
|
||||
|
||||
@Autowired
|
||||
private YxUserBillService billService;
|
||||
|
||||
|
||||
@Override
|
||||
public void incIntegral(int uid, double integral) {
|
||||
yxUserMapper.incIntegral(integral,uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一级返佣
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean backOrderBrokerage(YxStoreOrderQueryVo order) {
|
||||
//todo 拼团等
|
||||
//支付金额减掉邮费
|
||||
double payPrice = 0d;
|
||||
payPrice = NumberUtil.sub(order.getPayPrice(),order.getPayPostage()).doubleValue();
|
||||
|
||||
//获取购买商品的用户
|
||||
YxUserQueryVo userInfo = getYxUserById(order.getUid());
|
||||
//当前用户不存在 没有上级 直接返回
|
||||
if(ObjectUtil.isNull(userInfo) || userInfo.getSpreadUid() == 0) return true;
|
||||
|
||||
//获取后台分销类型 1 指定分销 2 人人分销
|
||||
int storeBrokerageStatus = 1;
|
||||
if(StrUtil.isNotEmpty(systemConfigService.getData("store_brokerage_statu"))){
|
||||
storeBrokerageStatus = Integer.valueOf(systemConfigService
|
||||
.getData("store_brokerage_statu"));
|
||||
}
|
||||
|
||||
//指定分销 判断 上级是否时推广员 如果不是推广员直接跳转二级返佣
|
||||
YxUserQueryVo preUser = getYxUserById(userInfo.getSpreadUid());
|
||||
if(storeBrokerageStatus == 1){
|
||||
|
||||
if(preUser.getIsPromoter() == 0){
|
||||
return backOrderBrokerageTwo(order);
|
||||
}
|
||||
}
|
||||
|
||||
//获取后台一级返佣比例
|
||||
String storeBrokerageRatioStr = systemConfigService.getData("store_brokerage_ratio");
|
||||
int storeBrokerageRatio = 0;
|
||||
if(StrUtil.isNotEmpty(storeBrokerageRatioStr)){
|
||||
storeBrokerageRatio = Integer.valueOf(storeBrokerageRatioStr);
|
||||
}
|
||||
//一级返佣比例 等于零时直接返回 不返佣
|
||||
if(storeBrokerageRatio == 0) return true;
|
||||
|
||||
//计算获取一级返佣比例
|
||||
double brokerageRatio = NumberUtil.div(storeBrokerageRatio,100);
|
||||
//成本价
|
||||
double cost = order.getCost().doubleValue();
|
||||
|
||||
//成本价大于等于支付价格时直接返回
|
||||
if(cost >= payPrice) return true;
|
||||
|
||||
//获取订单毛利
|
||||
payPrice = NumberUtil.sub(payPrice,cost);
|
||||
|
||||
//返佣金额 = 毛利 / 一级返佣比例
|
||||
double brokeragePrice = NumberUtil.mul(payPrice,brokerageRatio);
|
||||
|
||||
//返佣金额小于等于0 直接返回不返佣金
|
||||
if(brokeragePrice <=0 ) return true;
|
||||
|
||||
//计算上级推广员返佣之后的金额
|
||||
double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice)
|
||||
.doubleValue();
|
||||
String mark = userInfo.getNickname()+"成功消费"+order.getPayPrice()+"元,奖励推广佣金"+
|
||||
brokeragePrice;
|
||||
//插入流水
|
||||
YxUserBill userBill = new YxUserBill();
|
||||
userBill.setUid(userInfo.getSpreadUid());
|
||||
userBill.setTitle("获得推广佣金");
|
||||
userBill.setLinkId(order.getId().toString());
|
||||
userBill.setCategory("now_money");
|
||||
userBill.setType("brokerage");
|
||||
userBill.setNumber(BigDecimal.valueOf(brokeragePrice));
|
||||
userBill.setBalance(BigDecimal.valueOf(balance));
|
||||
userBill.setMark(mark);
|
||||
userBill.setStatus(1);
|
||||
userBill.setPm(1);
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
//添加用户余额
|
||||
yxUserMapper.incBrokeragePrice(brokeragePrice,
|
||||
userInfo.getSpreadUid());
|
||||
|
||||
//一级返佣成功 跳转二级返佣
|
||||
backOrderBrokerageTwo(order);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级返佣
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean backOrderBrokerageTwo(YxStoreOrderQueryVo order) {
|
||||
|
||||
double payPrice = 0d;
|
||||
payPrice = NumberUtil.sub(order.getPayPrice(),order.getPayPostage()).doubleValue();
|
||||
|
||||
YxUserQueryVo userInfo = getYxUserById(order.getUid());
|
||||
|
||||
//获取上推广人
|
||||
YxUserQueryVo userInfoTwo = getYxUserById(userInfo.getSpreadUid());
|
||||
|
||||
//上推广人不存在 或者 上推广人没有上级 直接返回
|
||||
if(ObjectUtil.isNull(userInfoTwo) || userInfoTwo.getSpreadUid() == 0) return true;
|
||||
|
||||
//获取后台分销类型 1 指定分销 2 人人分销
|
||||
int storeBrokerageStatus = 1;
|
||||
if(StrUtil.isNotEmpty(systemConfigService.getData("store_brokerage_statu"))){
|
||||
storeBrokerageStatus = Integer.valueOf(systemConfigService
|
||||
.getData("store_brokerage_statu"));
|
||||
}
|
||||
//指定分销 判断 上上级是否时推广员 如果不是推广员直接返回
|
||||
YxUserQueryVo preUser = getYxUserById(userInfoTwo.getSpreadUid());
|
||||
if(storeBrokerageStatus == 1){
|
||||
|
||||
if(preUser.getIsPromoter() == 0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//获取二级返佣比例
|
||||
String storeBrokerageTwoStr = systemConfigService.getData("store_brokerage_two");
|
||||
int storeBrokerageTwo = 0;
|
||||
if(StrUtil.isNotEmpty(storeBrokerageTwoStr)){
|
||||
storeBrokerageTwo = Integer.valueOf(storeBrokerageTwoStr);
|
||||
}
|
||||
//一级返佣比例 等于零时直接返回 不返佣
|
||||
if(storeBrokerageTwo == 0) return true;
|
||||
|
||||
//计算获取二级返佣比例
|
||||
double brokerageRatio = NumberUtil.div(storeBrokerageTwo,100);
|
||||
//成本价
|
||||
double cost = order.getCost().doubleValue();
|
||||
|
||||
//成本价大于等于支付价格时直接返回
|
||||
if(cost >= payPrice) return true;
|
||||
|
||||
//获取订单毛利
|
||||
payPrice = NumberUtil.sub(payPrice,cost);
|
||||
|
||||
//返佣金额 = 毛利 / 二级返佣比例
|
||||
double brokeragePrice = NumberUtil.mul(payPrice,brokerageRatio);
|
||||
|
||||
//返佣金额小于等于0 直接返回不返佣金
|
||||
if(brokeragePrice <=0 ) return true;
|
||||
|
||||
//获取上上级推广员信息
|
||||
double balance = NumberUtil.add(preUser.getBrokeragePrice(),brokeragePrice)
|
||||
.doubleValue();
|
||||
String mark = "二级推广人"+userInfo.getNickname()+"成功消费"+order.getPayPrice()+"元,奖励推广佣金"+
|
||||
brokeragePrice;
|
||||
//插入流水
|
||||
YxUserBill userBill = new YxUserBill();
|
||||
userBill.setUid(userInfoTwo.getSpreadUid());
|
||||
userBill.setTitle("获得推广佣金");
|
||||
userBill.setLinkId(order.getId().toString());
|
||||
userBill.setCategory("now_money");
|
||||
userBill.setType("brokerage");
|
||||
userBill.setNumber(BigDecimal.valueOf(brokeragePrice));
|
||||
userBill.setBalance(BigDecimal.valueOf(balance));
|
||||
userBill.setMark(mark);
|
||||
userBill.setStatus(1);
|
||||
userBill.setPm(1);
|
||||
userBill.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
billService.save(userBill);
|
||||
|
||||
//添加用户余额
|
||||
yxUserMapper.incBrokeragePrice(brokeragePrice,
|
||||
userInfoTwo.getSpreadUid());
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserSpreadCount(int uid) {
|
||||
QueryWrapper<YxUser> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("spread_uid",uid);
|
||||
int count = yxUserMapper.selectCount(wrapper);
|
||||
|
||||
YxUser user = new YxUser();
|
||||
user.setUid(uid);
|
||||
user.setSpreadCount(count);
|
||||
|
||||
yxUserMapper.updateById(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpreadCount(int uid, int type) {
|
||||
QueryWrapper<YxUser> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("spread_uid",uid);
|
||||
int count = 0;
|
||||
if(type == 1){
|
||||
count = yxUserMapper.selectCount(wrapper);
|
||||
}else{
|
||||
List<YxUser> userList = yxUserMapper.selectList(wrapper);
|
||||
List<Integer> userIds = userList.stream().map(YxUser::getUid)
|
||||
.collect(Collectors.toList());
|
||||
if(userIds.isEmpty()) {
|
||||
count = 0;
|
||||
}else{
|
||||
QueryWrapper<YxUser> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.in("spread_uid",userIds);
|
||||
|
||||
count = yxUserMapper.selectCount(wrapperT);
|
||||
}
|
||||
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PromUserDTO> getUserSpreadGrade(PromParam promParam,int uid) {
|
||||
QueryWrapper<YxUser> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("spread_uid",uid);
|
||||
List<YxUser> userList = yxUserMapper.selectList(wrapper);
|
||||
List<Integer> userIds = userList.stream().map(YxUser::getUid)
|
||||
.collect(Collectors.toList());
|
||||
List<PromUserDTO> list = new ArrayList<>();
|
||||
if(userIds.isEmpty()) return list;
|
||||
String sort;
|
||||
if(StrUtil.isEmpty(promParam.getSort())){
|
||||
sort = "u.add_time desc";
|
||||
}else{
|
||||
sort = promParam.getSort();
|
||||
}
|
||||
String keyword = null;
|
||||
if(StrUtil.isNotEmpty(promParam.getKeyword())){
|
||||
keyword = promParam.getKeyword();
|
||||
}
|
||||
Page<YxUser> pageModel = new Page<>(promParam.getPage(), promParam.getLimit());
|
||||
if(promParam.getGrade() == 0){//-级
|
||||
list = yxUserMapper.getUserSpreadCountList(pageModel,userIds,
|
||||
keyword,sort);
|
||||
}else{//二级
|
||||
QueryWrapper<YxUser> wrapperT = new QueryWrapper<>();
|
||||
wrapperT.in("spread_uid",userIds);
|
||||
List<YxUser> userListT = yxUserMapper.selectList(wrapperT);
|
||||
List<Integer> userIdsT = userListT.stream().map(YxUser::getUid)
|
||||
.collect(Collectors.toList());
|
||||
if(userIdsT.isEmpty()) return list;
|
||||
list = yxUserMapper.getUserSpreadCountList(pageModel,userIdsT,
|
||||
keyword,sort);
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置推广关系
|
||||
* @param spread
|
||||
* @param uid
|
||||
*/
|
||||
@Override
|
||||
public boolean setSpread(int spread, int uid) {
|
||||
//当前用户信息
|
||||
YxUserQueryVo userInfo = getYxUserById(uid);
|
||||
if(ObjectUtil.isNull(userInfo)) return true;
|
||||
|
||||
//当前用户有上级直接返回
|
||||
if(userInfo.getSpreadUid() > 0) return true;
|
||||
//没有推广编号直接返回
|
||||
if(spread == 0) return true;
|
||||
if(spread == uid) return true;
|
||||
|
||||
//不能互相成为上下级
|
||||
YxUserQueryVo userInfoT = getYxUserById(spread);
|
||||
if(ObjectUtil.isNull(userInfoT)) return true;
|
||||
|
||||
if(userInfoT.getSpreadUid() == uid) return true;
|
||||
|
||||
//1-指定分销 2-人人分销
|
||||
//int storeBrokerageStatus = Integer.valueOf(systemConfigService
|
||||
// .getData("store_brokerage_statu"));
|
||||
//storeBrokerageStatus
|
||||
YxUser yxUser = new YxUser();
|
||||
|
||||
yxUser.setSpreadUid(spread);
|
||||
yxUser.setSpreadTime(OrderUtil.getSecondTimestampTwo());
|
||||
yxUser.setUid(uid);
|
||||
yxUserMapper.updateById(yxUser);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incPayCount(int uid) {
|
||||
@ -50,10 +366,29 @@ public class YxUserServiceImpl extends BaseServiceImpl<YxUserMapper, YxUser> imp
|
||||
yxUserMapper.decPrice(payPrice,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decIntegral(int uid, double integral) {
|
||||
yxUserMapper.decIntegral(integral,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxUserQueryVo getYxUserById(Serializable id){
|
||||
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
||||
//userQueryVo.setOrderStatusNum(orderService.orderData((int)id));
|
||||
return userQueryVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxUserQueryVo getNewYxUserById(Serializable id) {
|
||||
YxUserQueryVo userQueryVo = yxUserMapper.getYxUserById(id);
|
||||
userQueryVo.setOrderStatusNum(orderService.orderData((int)id));
|
||||
//判断分销类型
|
||||
String statu = systemConfigService.getData("store_brokerage_statu");
|
||||
if(StrUtil.isNotEmpty(statu)){
|
||||
userQueryVo.setStatu(Integer.valueOf(statu));
|
||||
}else{
|
||||
userQueryVo.setStatu(0);
|
||||
}
|
||||
return userQueryVo;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,274 @@
|
||||
package co.yixiang.modules.user.web.controller;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.user.entity.YxSystemAttachment;
|
||||
import co.yixiang.modules.user.service.YxSystemAttachmentService;
|
||||
import co.yixiang.modules.user.service.YxUserBillService;
|
||||
import co.yixiang.modules.user.service.YxUserExtractService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.param.PromParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName UserBillController
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/10
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@Api(value = "用户分销", tags = "用户分销", description = "用户分销")
|
||||
public class UserBillController extends BaseController {
|
||||
|
||||
private final YxUserBillService userBillService;
|
||||
private final YxUserExtractService extractService;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
private final YxUserService yxUserService;
|
||||
private final YxSystemAttachmentService systemAttachmentService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 推广数据 昨天的佣金 累计提现金额 当前佣金
|
||||
*/
|
||||
@GetMapping("/commission")
|
||||
@ApiOperation(value = "推广数据",notes = "推广数据")
|
||||
public ApiResult<Object> commission(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
|
||||
//判断分销类型
|
||||
String statu = systemConfigService.getData("store_brokerage_statu");
|
||||
if(StrUtil.isNotEmpty(statu)){
|
||||
if(Integer.valueOf(statu) == 1){
|
||||
YxUserQueryVo userQueryVo = yxUserService.getYxUserById(uid);
|
||||
if(userQueryVo.getIsPromoter() == 0){
|
||||
return ApiResult.fail("你不是推广员哦!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//昨天的佣金
|
||||
double lastDayCount = userBillService.yesterdayCommissionSum(uid);
|
||||
//累计提现金额
|
||||
double extractCount = extractService.extractSum(uid);
|
||||
//获取总佣金
|
||||
double commissionCount = userBillService.getBrokerage(uid);
|
||||
|
||||
//计算当前拥有的佣金
|
||||
if(commissionCount > 0){
|
||||
|
||||
}
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("lastDayCount",lastDayCount);
|
||||
map.put("extractCount",extractCount);
|
||||
map.put("commissionCount",commissionCount);
|
||||
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分记录
|
||||
*/
|
||||
@GetMapping("/integral/list")
|
||||
@ApiOperation(value = "积分记录",notes = "积分记录")
|
||||
public ApiResult<Object> userInfo(@RequestParam(value = "page",defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit",defaultValue = "10") int limit){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(userBillService.userBillList(uid,page,limit,"integral"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销二维码海报生成
|
||||
*/
|
||||
@GetMapping("/spread/banner")
|
||||
@ApiOperation(value = "分销二维码海报生成",notes = "分销二维码海报生成")
|
||||
public ApiResult<Object> spreadBanner(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
YxUserQueryVo userInfo = yxUserService.getYxUserById(uid);
|
||||
String siteUrl = systemConfigService.getData("site_url");
|
||||
if(StrUtil.isEmpty(siteUrl)){
|
||||
return ApiResult.fail("未配置h5地址");
|
||||
}
|
||||
String apiUrl = systemConfigService.getData("api_url");
|
||||
if(StrUtil.isEmpty(siteUrl)){
|
||||
return ApiResult.fail("未配置api地址");
|
||||
}
|
||||
String name = uid + "_"+userInfo.getIsPromoter()+"_user_wap.jpg";
|
||||
|
||||
YxSystemAttachment attachment = systemAttachmentService.getInfo(name);
|
||||
String fileDir = path+"qrcode"+File.separator;
|
||||
String qrcodeUrl = "";
|
||||
if(ObjectUtil.isNull(attachment)){
|
||||
//生成二维码
|
||||
//String fileDir = path+"qrcode"+File.separator;
|
||||
File file = FileUtil.mkdir(new File(fileDir));
|
||||
QrCodeUtil.generate(siteUrl+"?spread="+uid, 180, 180,
|
||||
FileUtil.file(fileDir+name));
|
||||
|
||||
systemAttachmentService.attachmentAdd(name,String.valueOf(FileUtil.size(file)),
|
||||
fileDir+name,"qrcode/"+name);
|
||||
|
||||
qrcodeUrl = fileDir+name;
|
||||
}else{
|
||||
qrcodeUrl = attachment.getAttDir();
|
||||
}
|
||||
|
||||
|
||||
String spreadPicName = uid + "_"+userInfo.getIsPromoter()+"_user_spread.jpg";
|
||||
String spreadPicPath = fileDir+spreadPicName;
|
||||
|
||||
YxSystemAttachment attachmentT = systemAttachmentService.getInfo(spreadPicName);
|
||||
String spreadUrl = "";
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream("fx.jpg");
|
||||
InputStream streamT = getClass().getClassLoader()
|
||||
.getResourceAsStream("simsunb.ttf");
|
||||
File newFile = new File("fx.jpg");
|
||||
File newFileT = new File("simsunb.ttf");
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(stream, newFile);
|
||||
FileUtils.copyInputStreamToFile(streamT, newFileT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isNull(attachmentT)){
|
||||
try {
|
||||
|
||||
// Font font = new Font(newFileT.getAbsolutePath(), Font.BOLD, 20);
|
||||
Font font = Font.createFont(Font.TRUETYPE_FONT, newFileT);
|
||||
Font f= font.deriveFont(Font.PLAIN,20);
|
||||
//font.
|
||||
ImgUtil.pressText(//
|
||||
newFile,
|
||||
FileUtil.file(spreadPicPath),
|
||||
userInfo.getNickname()+"邀您加入",
|
||||
Color.BLACK,
|
||||
f, //字体
|
||||
50, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
300, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f//透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
|
||||
);
|
||||
|
||||
ImgUtil.pressImage(
|
||||
FileUtil.file(spreadPicPath),
|
||||
FileUtil.file(spreadPicPath),
|
||||
ImgUtil.read(FileUtil.file(qrcodeUrl)), //水印图片
|
||||
-150, //x坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
340, //y坐标修正值。 默认在中间,偏移量相对于中间偏移
|
||||
0.8f
|
||||
);
|
||||
|
||||
systemAttachmentService.attachmentAdd(spreadPicName,
|
||||
String.valueOf(FileUtil.size(new File(spreadPicPath))),
|
||||
spreadPicPath,"qrcode/"+spreadPicName);
|
||||
|
||||
spreadUrl = apiUrl + "/api/file/qrcode/"+spreadPicName;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
spreadUrl = apiUrl + "/api/file/" + attachmentT.getSattDir();
|
||||
}
|
||||
|
||||
|
||||
java.util.List<Map<String,Object>> list = new ArrayList<>();
|
||||
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("id",1);
|
||||
map.put("pic","");
|
||||
map.put("title","分享海报");
|
||||
map.put("wap_poster",spreadUrl);
|
||||
list.add(map);
|
||||
return ApiResult.ok(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推荐用户
|
||||
* grade == 0 获取一级推荐人
|
||||
* grade == 其他 获取二级推荐人
|
||||
* keyword 会员名称查询
|
||||
* sort childCount ASC/DESC 团队排序 numberCount ASC/DESC
|
||||
* 金额排序 orderCount ASC/DESC 订单排序
|
||||
*/
|
||||
@PostMapping("/spread/people")
|
||||
@ApiOperation(value = "推荐用户",notes = "推荐用户")
|
||||
public ApiResult<Object> spreadPeople(@Valid @RequestBody PromParam param){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("list",yxUserService.getUserSpreadGrade(param,uid));
|
||||
map.put("total",yxUserService.getSpreadCount(uid,1));
|
||||
map.put("totalLevel",yxUserService.getSpreadCount(uid,2));
|
||||
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推广佣金明细
|
||||
* type 0 全部 1 消费 2 充值 3 返佣 4 提现
|
||||
* @return mixed
|
||||
*/
|
||||
@GetMapping("/spread/commission/{type}")
|
||||
@ApiOperation(value = "推广佣金明细",notes = "推广佣金明细")
|
||||
public ApiResult<Object> spreadCommission(@RequestParam(value = "page",defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit",defaultValue = "10") int limit,
|
||||
@PathVariable int type){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
|
||||
return ApiResult.ok(userBillService.getUserBillList(page,limit,uid,type));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推广订单
|
||||
*/
|
||||
@PostMapping("/spread/order")
|
||||
@ApiOperation(value = "推广订单",notes = "推广订单")
|
||||
public ApiResult<Object> spreadOrder(@RequestBody String jsonStr){
|
||||
JSONObject jsonObject = JSON.parseObject(jsonStr);
|
||||
if(ObjectUtil.isNull(jsonObject.get("page")) || ObjectUtil.isNull(jsonObject.get("limit"))){
|
||||
return ApiResult.fail("参数错误");
|
||||
}
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
Map<String, Object> map = userBillService.spreadOrder(uid,Integer.valueOf(jsonObject.get("page").toString())
|
||||
,Integer.valueOf(jsonObject.get("limit").toString()));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -51,6 +51,8 @@ public class UserController extends BaseController {
|
||||
@ApiOperation(value = "获取用户信息",notes = "获取用户信息",response = YxUserQueryVo.class)
|
||||
public ApiResult<Object> userInfo(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
//update count
|
||||
yxUserService.setUserSpreadCount(uid);
|
||||
return ApiResult.ok(yxUserService.getYxUserById(uid));
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ public class UserController extends BaseController {
|
||||
@ApiOperation(value = "个人中心",notes = "个人中心")
|
||||
public ApiResult<Object> user(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(yxUserService.getYxUserById(uid));
|
||||
return ApiResult.ok(yxUserService.getNewYxUserById(uid));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -129,10 +131,12 @@ public class UserController extends BaseController {
|
||||
@PostMapping("/sign/user")
|
||||
@ApiOperation(value = "获取活动状态",notes = "获取活动状态")
|
||||
public ApiResult<Object> sign(){
|
||||
return ApiResult.fail("开发中");
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
return ApiResult.ok(yxUserService.getYxUserById(uid));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
package co.yixiang.modules.user.web.controller;
|
||||
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.user.entity.YxUserExtract;
|
||||
import co.yixiang.modules.user.service.YxUserExtractService;
|
||||
import co.yixiang.modules.user.service.YxUserService;
|
||||
import co.yixiang.modules.user.web.param.UserExtParam;
|
||||
import co.yixiang.modules.user.web.param.YxUserExtractQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserExtractQueryVo;
|
||||
import co.yixiang.modules.user.web.vo.YxUserQueryVo;
|
||||
import co.yixiang.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@Api(value = "用户提现", tags = "用户提现", description = "用户提现")
|
||||
public class UserExtractController extends BaseController {
|
||||
|
||||
|
||||
private final YxUserExtractService userExtractService;
|
||||
private final YxUserService userService;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
|
||||
/**
|
||||
* 提现参数
|
||||
*/
|
||||
@GetMapping("/extract/bank")
|
||||
@ApiOperation(value = "提现参数",notes = "提现参数")
|
||||
public ApiResult<Object> bank(){
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
YxUserQueryVo userInfo = userService.getYxUserById(uid);
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("commissionCount",userInfo.getBrokeragePrice());
|
||||
map.put("minPrice",systemConfigService.getData("user_extract_min_price"));
|
||||
return ApiResult.ok(map);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户提现
|
||||
*/
|
||||
@PostMapping("/extract/cash")
|
||||
@ApiOperation(value = "用户提现",notes = "用户提现")
|
||||
public ApiResult<Boolean> addYxUserExtract(@Valid @RequestBody UserExtParam param) throws Exception{
|
||||
int uid = SecurityUtils.getUserId().intValue();
|
||||
userExtractService.userExtract(uid,param);
|
||||
|
||||
return ApiResult.ok("申请提现成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户提现表分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取YxUserExtract分页列表",notes = "用户提现表分页列表",response = YxUserExtractQueryVo.class)
|
||||
public ApiResult<Paging<YxUserExtractQueryVo>> getYxUserExtractPageList(@Valid @RequestBody(required = false) YxUserExtractQueryParam yxUserExtractQueryParam) throws Exception{
|
||||
Paging<YxUserExtractQueryVo> paging = userExtractService.getYxUserExtractPageList(yxUserExtractQueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,91 @@
|
||||
package co.yixiang.modules.user.web.controller;
|
||||
|
||||
import co.yixiang.modules.user.entity.YxUserExtract;
|
||||
import co.yixiang.modules.user.service.YxUserExtractService;
|
||||
import co.yixiang.modules.user.web.param.YxUserExtractQueryParam;
|
||||
import co.yixiang.modules.user.web.vo.YxUserExtractQueryVo;
|
||||
import co.yixiang.common.web.controller.BaseController;
|
||||
import co.yixiang.common.api.ApiResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import co.yixiang.common.web.vo.Paging;
|
||||
import co.yixiang.common.web.param.IdParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @since 2019-11-11
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/yxUserExtract")
|
||||
@Api("用户提现表 API")
|
||||
public class YxUserExtractController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private YxUserExtractService yxUserExtractService;
|
||||
|
||||
/**
|
||||
* 添加用户提现表
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加YxUserExtract对象",notes = "添加用户提现表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> addYxUserExtract(@Valid @RequestBody YxUserExtract yxUserExtract) throws Exception{
|
||||
boolean flag = yxUserExtractService.save(yxUserExtract);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户提现表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改YxUserExtract对象",notes = "修改用户提现表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> updateYxUserExtract(@Valid @RequestBody YxUserExtract yxUserExtract) throws Exception{
|
||||
boolean flag = yxUserExtractService.updateById(yxUserExtract);
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户提现表
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "删除YxUserExtract对象",notes = "删除用户提现表",response = ApiResult.class)
|
||||
public ApiResult<Boolean> deleteYxUserExtract(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
boolean flag = yxUserExtractService.removeById(idParam.getId());
|
||||
return ApiResult.result(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户提现表
|
||||
*/
|
||||
@PostMapping("/info")
|
||||
@ApiOperation(value = "获取YxUserExtract对象详情",notes = "查看用户提现表",response = YxUserExtractQueryVo.class)
|
||||
public ApiResult<YxUserExtractQueryVo> getYxUserExtract(@Valid @RequestBody IdParam idParam) throws Exception{
|
||||
YxUserExtractQueryVo yxUserExtractQueryVo = yxUserExtractService.getYxUserExtractById(idParam.getId());
|
||||
return ApiResult.ok(yxUserExtractQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户提现表分页列表
|
||||
*/
|
||||
@PostMapping("/getPageList")
|
||||
@ApiOperation(value = "获取YxUserExtract分页列表",notes = "用户提现表分页列表",response = YxUserExtractQueryVo.class)
|
||||
public ApiResult<Paging<YxUserExtractQueryVo>> getYxUserExtractPageList(@Valid @RequestBody(required = false) YxUserExtractQueryParam yxUserExtractQueryParam) throws Exception{
|
||||
Paging<YxUserExtractQueryVo> paging = yxUserExtractService.getYxUserExtractPageList(yxUserExtractQueryParam);
|
||||
return ApiResult.ok(paging);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BillDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class BillDTO {
|
||||
private String time;
|
||||
@JsonIgnore
|
||||
private String ids;
|
||||
private List<UserBillDTO> list;
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BillDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class BillOrderDTO {
|
||||
private String time;
|
||||
private Integer count;
|
||||
private List<BillOrderRecordDTO> child;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName BillDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class BillOrderRecordDTO {
|
||||
private String orderId;
|
||||
private String time;
|
||||
private Double number;
|
||||
private String avatar;
|
||||
private String nickname;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName PromUserDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class PromUserDTO {
|
||||
private String avatar;
|
||||
private String nickname;
|
||||
private Integer childCount;
|
||||
private Integer numberCount;
|
||||
private Integer orderCount;
|
||||
private Integer uid;
|
||||
private String time;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName UserBillDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class UserBillDTO {
|
||||
private String addTime;
|
||||
private String title;
|
||||
private Double number;
|
||||
private Integer pm;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package co.yixiang.modules.user.web.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName UserRankDTO
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/13
|
||||
**/
|
||||
@Data
|
||||
public class UserRankDTO {
|
||||
private Integer uid;
|
||||
private Integer count;
|
||||
private String nickname;
|
||||
private String avatar;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package co.yixiang.modules.user.web.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName PromParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/12
|
||||
**/
|
||||
@Data
|
||||
public class PromParam implements Serializable {
|
||||
private Integer grade;
|
||||
private String keyword;
|
||||
private Integer limit;
|
||||
private Integer page;
|
||||
private String sort;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package co.yixiang.modules.user.web.param;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName UserExtParam
|
||||
* @Author hupeng <610796224@qq.com>
|
||||
* @Date 2019/11/13
|
||||
**/
|
||||
@Data
|
||||
public class UserExtParam implements Serializable {
|
||||
|
||||
//支付宝用户名
|
||||
private String alipayCode;
|
||||
|
||||
@NotBlank(message = "体现类型不能为空")
|
||||
private String extractType;
|
||||
|
||||
@NotBlank(message = "金额不能为空")
|
||||
private String money;
|
||||
|
||||
//微信号
|
||||
private String weixin;
|
||||
|
||||
//支付宝账号
|
||||
private String name;
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package co.yixiang.modules.user.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import co.yixiang.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxSystemAttachmentQueryParam对象", description="附件管理表查询参数")
|
||||
public class YxSystemAttachmentQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@ -19,4 +19,5 @@ import co.yixiang.common.web.param.QueryParam;
|
||||
@ApiModel(value="YxUserBillQueryParam对象", description="用户账单表查询参数")
|
||||
public class YxUserBillQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package co.yixiang.modules.user.web.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import co.yixiang.common.web.param.QueryParam;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value="YxUserExtractQueryParam对象", description="用户提现表查询参数")
|
||||
public class YxUserExtractQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package co.yixiang.modules.user.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件管理表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxSystemAttachmentQueryVo对象", description="附件管理表查询参数")
|
||||
public class YxSystemAttachmentQueryVo implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer attId;
|
||||
|
||||
@ApiModelProperty(value = "附件名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "附件路径")
|
||||
private String attDir;
|
||||
|
||||
@ApiModelProperty(value = "压缩图片路径")
|
||||
private String sattDir;
|
||||
|
||||
@ApiModelProperty(value = "附件大小")
|
||||
private String attSize;
|
||||
|
||||
@ApiModelProperty(value = "附件类型")
|
||||
private String attType;
|
||||
|
||||
@ApiModelProperty(value = "分类ID0编辑器,1产品图片,2拼团图片,3砍价图片,4秒杀图片,5文章图片,6组合数据图")
|
||||
private Integer pid;
|
||||
|
||||
@ApiModelProperty(value = "上传时间")
|
||||
private Integer time;
|
||||
|
||||
@ApiModelProperty(value = "图片上传类型 1本地 2七牛云 3OSS 4COS ")
|
||||
private Boolean imageType;
|
||||
|
||||
@ApiModelProperty(value = "图片上传模块类型 1 后台上传 2 用户生成")
|
||||
private Boolean moduleType;
|
||||
|
||||
}
|
||||
@ -3,6 +3,7 @@ package co.yixiang.modules.user.web.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -17,44 +18,31 @@ import java.util.Date;
|
||||
* @date 2019-10-27
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value="YxUserBillQueryVo对象", description="用户账单表查询参数")
|
||||
public class YxUserBillQueryVo implements Serializable{
|
||||
@ApiModel(value = "YxUserBillQueryVo对象", description = "用户账单表查询参数")
|
||||
public class YxUserBillQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "用户账单id")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "用户账单id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "用户uid")
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "关联id")
|
||||
private String linkId;
|
||||
|
||||
@ApiModelProperty(value = "0 = 支出 1 = 获得")
|
||||
private Boolean pm;
|
||||
@ApiModelProperty(value = "0 = 支出 1 = 获得")
|
||||
private Integer pm;
|
||||
|
||||
@ApiModelProperty(value = "账单标题")
|
||||
private String title;
|
||||
@ApiModelProperty(value = "账单标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "明细种类")
|
||||
private String category;
|
||||
@ApiModelProperty(value = "明细数字")
|
||||
private BigDecimal number;
|
||||
|
||||
@ApiModelProperty(value = "明细类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "明细数字")
|
||||
private BigDecimal number;
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String mark;
|
||||
|
||||
@ApiModelProperty(value = "剩余")
|
||||
private BigDecimal balance;
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String mark;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "0 = 带确定 1 = 有效 -1 = 无效")
|
||||
private Boolean status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package co.yixiang.modules.user.web.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户提现表 查询结果对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2019-11-11
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "YxUserExtractQueryVo对象", description = "用户提现表查询参数")
|
||||
public class YxUserExtractQueryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer uid;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "bank = 银行卡 alipay = 支付宝wx=微信")
|
||||
private String extractType;
|
||||
|
||||
@ApiModelProperty(value = "银行卡")
|
||||
private String bankCode;
|
||||
|
||||
@ApiModelProperty(value = "开户地址")
|
||||
private String bankAddress;
|
||||
|
||||
@ApiModelProperty(value = "支付宝账号")
|
||||
private String alipayCode;
|
||||
|
||||
@ApiModelProperty(value = "提现金额")
|
||||
private BigDecimal extractPrice;
|
||||
|
||||
private String mark;
|
||||
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty(value = "无效原因")
|
||||
private String failMsg;
|
||||
|
||||
private Integer failTime;
|
||||
|
||||
@ApiModelProperty(value = "添加时间")
|
||||
private Integer addTime;
|
||||
|
||||
@ApiModelProperty(value = "-1 未通过 0 审核中 1 已提现")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "微信号")
|
||||
private String wechat;
|
||||
|
||||
}
|
||||
@ -37,6 +37,8 @@ public class YxUserQueryVo implements Serializable {
|
||||
|
||||
private OrderCountDTO orderStatusNum;
|
||||
|
||||
private Integer statu;
|
||||
|
||||
|
||||
|
||||
// @ApiModelProperty(value = "用户密码(跟pwd)")
|
||||
@ -117,7 +119,7 @@ public class YxUserQueryVo implements Serializable {
|
||||
private String userType;
|
||||
|
||||
@ApiModelProperty(value = "是否为推广员")
|
||||
private Boolean isPromoter;
|
||||
private Integer isPromoter;
|
||||
|
||||
@ApiModelProperty(value = "用户购买次数")
|
||||
private Integer payCount;
|
||||
|
||||
@ -9,6 +9,7 @@ import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
import co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo;
|
||||
import co.yixiang.modules.security.security.JwtUser;
|
||||
import co.yixiang.modules.security.utils.JwtTokenUtil;
|
||||
import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
import co.yixiang.modules.user.entity.YxUser;
|
||||
import co.yixiang.modules.user.entity.YxWechatUser;
|
||||
import co.yixiang.modules.user.mapper.YxUserMapper;
|
||||
@ -26,7 +27,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.api.WxConsts;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
||||
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -55,6 +59,8 @@ public class WechatController extends BaseController {
|
||||
private final YxUserService userService;
|
||||
private final WxPayService wxPayService;
|
||||
private final YxStoreOrderService orderService;
|
||||
private final WxMpMessageRouter messageRouter;
|
||||
private final YxSystemConfigService systemConfigService;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
@ -64,6 +70,21 @@ public class WechatController extends BaseController {
|
||||
@Qualifier("jwtUserDetailsService")
|
||||
private UserDetailsService userDetailsService;
|
||||
|
||||
/**
|
||||
* 微信分享配置
|
||||
*/
|
||||
@GetMapping("/share")
|
||||
@ApiOperation(value = "微信分享配置",notes = "微信分享配置")
|
||||
public ApiResult<Object> share() {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("img",systemConfigService.getData("wechat_share_img"));
|
||||
map.put("title",systemConfigService.getData("wechat_share_title"));
|
||||
map.put("synopsis",systemConfigService.getData("wechat_share_synopsis"));
|
||||
Map<String,Object> mapt = new LinkedHashMap<>();
|
||||
mapt.put("data",map);
|
||||
return ApiResult.ok(mapt);
|
||||
}
|
||||
|
||||
/**
|
||||
* jssdk配置
|
||||
*/
|
||||
@ -78,7 +99,8 @@ public class WechatController extends BaseController {
|
||||
*/
|
||||
@GetMapping("/wechat/auth")
|
||||
@ApiOperation(value = "微信授权",notes = "微信授权")
|
||||
public ApiResult<Object> authLogin(@RequestParam(value = "code") String code) {
|
||||
public ApiResult<Object> authLogin(@RequestParam(value = "code") String code,
|
||||
@RequestParam(value = "spread") String spread) {
|
||||
//todo 分销人
|
||||
//String url = "https://h5.dayouqiantu.cn/";
|
||||
//wxService.oauth2buildAuthorizationUrl(url, WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
|
||||
@ -88,17 +110,15 @@ public class WechatController extends BaseController {
|
||||
WxMpOAuth2AccessToken wxMpOAuth2AccessToken = wxService.oauth2getAccessToken(code);
|
||||
WxMpUser wxMpUser = wxService.oauth2getUserInfo(wxMpOAuth2AccessToken, null);
|
||||
String openid = wxMpUser.getOpenId();
|
||||
YxWechatUser wechatUser = wechatUserService.getUserInfo(openid);
|
||||
YxWechatUser wechatUser = wechatUserService.getUserInfo(openid);;
|
||||
JwtUser jwtUser = null;
|
||||
if(ObjectUtil.isNotNull(wechatUser)){
|
||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wechatUser.getNickname());
|
||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wechatUser.getOpenid());
|
||||
}else{
|
||||
|
||||
|
||||
//用户保存
|
||||
YxUser user = new YxUser();
|
||||
user.setAccount(wxMpUser.getNickname());
|
||||
user.setUsername(wxMpUser.getNickname());
|
||||
user.setUsername(wxMpUser.getOpenId());
|
||||
user.setPassword(EncryptUtils.encryptPassword("123456"));
|
||||
user.setPwd(EncryptUtils.encryptPassword("123456"));
|
||||
user.setPhone("");
|
||||
@ -147,10 +167,16 @@ public class WechatController extends BaseController {
|
||||
|
||||
|
||||
|
||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wxMpUser.getNickname());
|
||||
jwtUser = (JwtUser) userDetailsService.loadUserByUsername(wxMpUser.getOpenId());
|
||||
}
|
||||
|
||||
//System.out.println("jwtUser:"+jwtUser);
|
||||
|
||||
//设置推广关系
|
||||
if(StrUtil.isNotEmpty(spread) && !spread.equals("NaN")){
|
||||
//System.out.println("spread:"+spread);
|
||||
userService.setSpread(Integer.valueOf(spread),
|
||||
jwtUser.getId().intValue());
|
||||
}
|
||||
|
||||
// 生成令牌
|
||||
final String token = jwtTokenUtil.generateToken(jwtUser);
|
||||
@ -195,6 +221,74 @@ public class WechatController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信验证消息
|
||||
*/
|
||||
@GetMapping("/wechat/serve")
|
||||
@ApiOperation(value = "微信验证消息",notes = "微信验证消息")
|
||||
public String authGet(@RequestParam(name = "signature", required = false) String signature,
|
||||
@RequestParam(name = "timestamp", required = false) String timestamp,
|
||||
@RequestParam(name = "nonce", required = false) String nonce,
|
||||
@RequestParam(name = "echostr", required = false) String echostr){
|
||||
|
||||
if (wxService.checkSignature(timestamp, nonce, signature)) {
|
||||
return echostr;
|
||||
}
|
||||
|
||||
return "fail";
|
||||
}
|
||||
|
||||
@PostMapping("/wechat/serve")
|
||||
public String post(@RequestBody String requestBody,
|
||||
@RequestParam("signature") String signature,
|
||||
@RequestParam("timestamp") String timestamp,
|
||||
@RequestParam("nonce") String nonce,
|
||||
@RequestParam("openid") String openid,
|
||||
@RequestParam(name = "encrypt_type", required = false) String encType,
|
||||
@RequestParam(name = "msg_signature", required = false) String msgSignature) {
|
||||
|
||||
|
||||
if (!wxService.checkSignature(timestamp, nonce, signature)) {
|
||||
throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
|
||||
}
|
||||
|
||||
String out = null;
|
||||
if (encType == null) {
|
||||
// 明文传输的消息
|
||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(requestBody);
|
||||
WxMpXmlOutMessage outMessage = this.route(inMessage);
|
||||
if (outMessage == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
out = outMessage.toXml();
|
||||
} else if ("aes".equalsIgnoreCase(encType)) {
|
||||
// aes加密的消息
|
||||
WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, wxService.getWxMpConfigStorage(),
|
||||
timestamp, nonce, msgSignature);
|
||||
WxMpXmlOutMessage outMessage = this.route(inMessage);
|
||||
if (outMessage == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
out = outMessage.toEncryptedXml(wxService.getWxMpConfigStorage());
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
private WxMpXmlOutMessage route(WxMpXmlMessage message) {
|
||||
try {
|
||||
return this.messageRouter.route(message);
|
||||
} catch (Exception e) {
|
||||
log.error("路由消息时出现异常!", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
BIN
yshop-api/src/main/resources/Alibaba-PuHuiTi-Regular.otf
Normal file
BIN
yshop-api/src/main/resources/Alibaba-PuHuiTi-Regular.otf
Normal file
Binary file not shown.
@ -77,4 +77,5 @@ file:
|
||||
avatar: E:\yshop\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
avatarMaxSize: 5
|
||||
localUrl: http://localhost:8000
|
||||
@ -6,7 +6,7 @@ spring:
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://localhost:3306/yshop?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
|
||||
username: yshop
|
||||
password:
|
||||
password: yshoP@2019#yx
|
||||
|
||||
# 初始化配置
|
||||
initial-size: 3
|
||||
@ -48,7 +48,7 @@ spring:
|
||||
database: 0
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
password:
|
||||
password: yshop2019@yxtw
|
||||
#连接超时时间
|
||||
timeout: 5000
|
||||
|
||||
@ -85,4 +85,5 @@ file:
|
||||
avatar: /home/yshop/avatar/
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
avatarMaxSize: 5
|
||||
localUrl: http://localhost:8000
|
||||
@ -52,13 +52,13 @@ mybatis-plus:
|
||||
wx:
|
||||
mp:
|
||||
configs:
|
||||
- appId: wx41db1daef9040a9e
|
||||
secret: a21b79510e45c76d6d543ef3ec020817
|
||||
token: dayouqiantu
|
||||
aesKey: 6wYzx9DyWXHwKSCOBjf8hHQu15d4JI5fVzDDNphaKqM
|
||||
- appId: wxc061dee8806ff712
|
||||
secret: 1dc5b2871d0d5ebd0f1ec7ddb856f805
|
||||
token: yshop
|
||||
aesKey: yYuBUkC8BXImCXyu7O6hkzLj4TC5nxsWPfL4CQAZPNY
|
||||
pay:
|
||||
appId: wx41db1daef9040a9e
|
||||
mchId: 1531087341
|
||||
appId: wxc061dee8806ff712
|
||||
mchId: 1493624002
|
||||
mchKey: dayouqiantuhupeng8638004yixiangt
|
||||
subAppId:
|
||||
subMchId:
|
||||
@ -69,3 +69,8 @@ logging:
|
||||
com.github.binarywang.demo.wx.mp: DEBUG
|
||||
me.chanjar.weixin: DEBUG
|
||||
|
||||
|
||||
#订单未付款订单时间(单位秒)
|
||||
job:
|
||||
unpayorder: 10
|
||||
|
||||
|
||||
BIN
yshop-api/src/main/resources/fx.jpg
Normal file
BIN
yshop-api/src/main/resources/fx.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<contextName>elAdmin</contextName>
|
||||
<contextName>yshop</contextName>
|
||||
|
||||
<!--输出到控制台-->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, order_id, uid, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, add_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, back_integral, mark, is_del, unique, remark, mer_id, is_mer_check, combination_id, pink_id, cost, seckill_id, bargain_id, verify_code, store_id, shipping_type, is_channel, is_remind, is_system_del
|
||||
id, order_id, uid, real_name, user_phone, user_address, cart_id, freight_price, total_num, total_price, total_postage, pay_price, pay_postage, deduction_price, coupon_id, coupon_price, paid, pay_time, pay_type, add_time, status, refund_status, refund_reason_wap_img, refund_reason_wap_explain, refund_reason_time, refund_reason_wap, refund_reason, refund_price, delivery_name, delivery_type, delivery_id, gain_integral, use_integral, back_integral, mark, is_del, `unique`, remark, mer_id, is_mer_check, combination_id, pink_id, cost, seckill_id, bargain_id, verify_code, store_id, shipping_type, is_channel, is_remind, is_system_del
|
||||
</sql>
|
||||
|
||||
<select id="getYxStoreOrderById" resultType="co.yixiang.modules.order.web.vo.YxStoreOrderQueryVo">
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, cid, title, author, image_input, synopsis, share_title, share_synopsis, visit, sort, url, status, add_time, hide, admin_id, mer_id, product_id, is_hot, is_banner
|
||||
id, cid, title, author, image_input, synopsis, share_title, share_synopsis, visit, sort, url, status, add_time, hide, admin_id, mer_id, product_id, is_hot, is_banner,content
|
||||
</sql>
|
||||
|
||||
<select id="getYxArticleById" resultType="co.yixiang.modules.shop.web.vo.YxArticleQueryVo">
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="co.yixiang.modules.user.mapper.YxSystemAttachmentMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
att_id, name, att_dir, satt_dir, att_size, att_type, pid, time, image_type, module_type
|
||||
</sql>
|
||||
|
||||
<select id="getYxSystemAttachmentById" resultType="co.yixiang.modules.user.web.vo.YxSystemAttachmentQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_system_attachment where att_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getYxSystemAttachmentPageList" resultType="co.yixiang.modules.user.web.vo.YxSystemAttachmentQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_system_attachment
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="co.yixiang.modules.user.mapper.YxUserExtractMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, uid, real_name, extract_type, bank_code, bank_address, alipay_code, extract_price, mark, balance, fail_msg, fail_time, add_time, status, wechat
|
||||
</sql>
|
||||
|
||||
<select id="getYxUserExtractById" resultType="co.yixiang.modules.user.web.vo.YxUserExtractQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_user_extract where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="getYxUserExtractPageList" resultType="co.yixiang.modules.user.web.vo.YxUserExtractQueryVo">
|
||||
select <include refid="Base_Column_List"/> from yx_user_extract
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -15,4 +15,5 @@
|
||||
select <include refid="Base_Column_List"/> from yx_user
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
BIN
yshop-api/src/main/resources/simsunb.ttf
Normal file
BIN
yshop-api/src/main/resources/simsunb.ttf
Normal file
Binary file not shown.
@ -45,9 +45,9 @@ public class CodeGenerator {
|
||||
// 作者
|
||||
private static final String AUTHOR = "hupeng";
|
||||
// 生成的表名称
|
||||
private static final String TABLE_NAME = "yx_user_address";
|
||||
private static final String TABLE_NAME = "yx_system_attachment";
|
||||
// 主键数据库列名称
|
||||
private static final String PK_ID_COLUMN_NAME = "id";
|
||||
private static final String PK_ID_COLUMN_NAME = "att_id";
|
||||
// 代码生成策略 true:All/false:SIMPLE
|
||||
private static final boolean GENERATOR_STRATEGY = true;
|
||||
// 分页列表查询是否排序 true:有排序参数/false:无
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>yshop</artifactId>
|
||||
<groupId>co.yixiang</groupId>
|
||||
<version>1.0</version>
|
||||
<version>1.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package co.yixiang.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@ -43,6 +44,15 @@ public class OrderUtil {
|
||||
return Integer.valueOf(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取精确到秒的时间戳
|
||||
* @return
|
||||
**/
|
||||
public static int dateToTimestamp(Date date){
|
||||
String timestamp = String.valueOf(date.getTime()/1000);
|
||||
return Integer.valueOf(timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态名称
|
||||
* @param paid
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user