商品和支付
parent
3f213a4ae6
commit
d624879f22
|
@ -563,4 +563,13 @@ public class Constants {
|
||||||
/** 公共JS配置 */
|
/** 公共JS配置 */
|
||||||
// CRMEB chat 统计
|
// CRMEB chat 统计
|
||||||
public static final String JS_CONFIG_CRMEB_CHAT_TONGJI="crmeb_tongji_js";
|
public static final String JS_CONFIG_CRMEB_CHAT_TONGJI="crmeb_tongji_js";
|
||||||
|
|
||||||
|
|
||||||
|
/** 退款理由 */
|
||||||
|
public static final String CONFIG_KEY_STOR_REASON = "stor_reason";
|
||||||
|
|
||||||
|
/** 订单支付成功后Task */
|
||||||
|
public static final String ORDER_TASK_PAY_SUCCESS_AFTER = "orderPaySuccessTask";
|
||||||
|
/** 订单收货后Task */
|
||||||
|
public static final String ORDER_TASK_REDIS_KEY_AFTER_TAKE_BY_USER = "alterOrderTakeByUser";
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class ServiceException extends RuntimeException {
|
||||||
this.message = errorCode.getMsg();
|
this.message = errorCode.getMsg();
|
||||||
}
|
}
|
||||||
public ServiceException( String message) {
|
public ServiceException( String message) {
|
||||||
this.code = GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode();
|
// this.code = GlobalErrorCodeants.INTERNAL_SERVER_ERROR.getCode();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
public ServiceException(Integer code, String message) {
|
public ServiceException(Integer code, String message) {
|
||||||
|
|
|
@ -198,15 +198,7 @@ public class DateUtils {
|
||||||
public static Date nowDateTime() {
|
public static Date nowDateTime() {
|
||||||
return strToDate(nowDateTimeStr(), Constants.DATE_FORMAT);
|
return strToDate(nowDateTimeStr(), Constants.DATE_FORMAT);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 获取当前日期,指定格式
|
|
||||||
* 描述:<描述函数实现的功能>.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String nowDateTimeStr() {
|
|
||||||
return nowDate(Constants.DATE_FORMAT);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 获取当前日期,指定格式
|
* 获取当前日期,指定格式
|
||||||
* 描述:<描述函数实现的功能>.
|
* 描述:<描述函数实现的功能>.
|
||||||
|
@ -218,6 +210,27 @@ public class DateUtils {
|
||||||
return dft.format(new Date());
|
return dft.format(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前日期,指定格式
|
||||||
|
* 描述:<描述函数实现的功能>.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String nowDateTimeStr() {
|
||||||
|
return nowDate(Constants.DATE_FORMAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前日期,指定格式
|
||||||
|
* 描述:<描述函数实现的功能>.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Integer getNowTime() {
|
||||||
|
long t = (System.currentTimeMillis()/1000L);
|
||||||
|
return Integer.parseInt(String.valueOf(t));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定日期加上天数后的日期
|
* 指定日期加上天数后的日期
|
||||||
*
|
*
|
||||||
|
@ -461,4 +474,31 @@ public class DateUtils {
|
||||||
}
|
}
|
||||||
return new DateLimitUtilVo(startTime, endTime);
|
return new DateLimitUtilVo(startTime, endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compare two date String with a pattern
|
||||||
|
*
|
||||||
|
* @param date1
|
||||||
|
* @param date2
|
||||||
|
* @param pattern
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int compareDate(String date1, String date2, String pattern) {
|
||||||
|
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(pattern);
|
||||||
|
try {
|
||||||
|
Date dt1 = DATE_FORMAT.parse(date1);
|
||||||
|
Date dt2 = DATE_FORMAT.parse(date2);
|
||||||
|
if (dt1.getTime() > dt2.getTime()) {
|
||||||
|
return 1;
|
||||||
|
} else if (dt1.getTime() < dt2.getTime()) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,16 @@
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-annotation</artifactId>
|
||||||
|
<version>3.5.3.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.product.api.property;
|
||||||
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
|
||||||
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@ -28,4 +29,5 @@ public class ProductPropertyValueApiImpl implements ProductPropertyValueApi {
|
||||||
productPropertyValueService.getPropertyValueDetailList(ids));
|
productPropertyValueService.getPropertyValueDetailList(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.product.service.property;
|
package cn.iocoder.yudao.module.product.service.property;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||||
|
@ -87,4 +88,11 @@ public interface ProductPropertyValueService {
|
||||||
*/
|
*/
|
||||||
void deletePropertyValueByPropertyId(Long propertyId);
|
void deletePropertyValueByPropertyId(Long propertyId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id、类型查询
|
||||||
|
* @param id ID
|
||||||
|
* @param type 类型
|
||||||
|
* @return StoreProductAttrValue
|
||||||
|
*/
|
||||||
|
ProductPropertyValueDetailRespDTO getByIdAndProductIdAndType(Integer id, Integer productId, Integer type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.property;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO;
|
||||||
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
|
||||||
|
@ -125,4 +126,9 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ
|
||||||
productPropertyValueMapper.deleteByPropertyId(propertyId);
|
productPropertyValueMapper.deleteByPropertyId(propertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProductPropertyValueDetailRespDTO getByIdAndProductIdAndType(Integer id, Integer productId, Integer type) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,29 +29,29 @@ public class OrderDataResponse implements Serializable {
|
||||||
private static final long serialVersionUID = 1387727608277207652L;
|
private static final long serialVersionUID = 1387727608277207652L;
|
||||||
|
|
||||||
@Schema(description = "已完成订单数量")
|
@Schema(description = "已完成订单数量")
|
||||||
private Integer completeCount;
|
private Long completeCount;
|
||||||
|
|
||||||
@Schema(description = "待核销订单数量")
|
@Schema(description = "待核销订单数量")
|
||||||
private Integer evaluatedCount;
|
private Long evaluatedCount;
|
||||||
|
|
||||||
// @Schema(description = "用户昵称")
|
// @Schema(description = "用户昵称")
|
||||||
// private Integer verificationCount;
|
// private Integer verificationCount;
|
||||||
|
|
||||||
@Schema(description = "支付订单总数")
|
@Schema(description = "支付订单总数")
|
||||||
private Integer orderCount;
|
private Long orderCount;
|
||||||
|
|
||||||
@Schema(description = "待收货订单数量")
|
@Schema(description = "待收货订单数量")
|
||||||
private Integer receivedCount;
|
private Long receivedCount;
|
||||||
|
|
||||||
@Schema(description = "退款订单数量")
|
@Schema(description = "退款订单数量")
|
||||||
private Integer refundCount;
|
private Long refundCount;
|
||||||
|
|
||||||
@Schema(description = "总消费钱数")
|
@Schema(description = "总消费钱数")
|
||||||
private BigDecimal sumPrice;
|
private BigDecimal sumPrice;
|
||||||
|
|
||||||
@Schema(description = "未支付订单数量")
|
@Schema(description = "未支付订单数量")
|
||||||
private Integer unPaidCount;
|
private Long unPaidCount;
|
||||||
|
|
||||||
@Schema(description = "待发货订单数量")
|
@Schema(description = "待发货订单数量")
|
||||||
private Integer unShippedCount;
|
private Long unShippedCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.shop.response.order;
|
package cn.iocoder.yudao.module.shop.response.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.shop.vo.order.WxPayJsResultVo;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -28,8 +29,8 @@ public class OrderPayResultResponse {
|
||||||
@Schema(description = "支付状态")
|
@Schema(description = "支付状态")
|
||||||
private Boolean status;
|
private Boolean status;
|
||||||
|
|
||||||
// @Schema(description = "微信调起支付参数对象")
|
@Schema(description = "微信调起支付参数对象")
|
||||||
// private WxPayJsResultVo jsConfig;
|
private WxPayJsResultVo jsConfig;
|
||||||
|
|
||||||
@Schema(description = "支付类型")
|
@Schema(description = "支付类型")
|
||||||
private String payType;
|
private String payType;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package cn.iocoder.yudao.module.shop.vo.order;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信调起支付参数对象
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@Schema(description="微信调起支付参数对象")
|
||||||
|
public class WxPayJsResultVo {
|
||||||
|
|
||||||
|
@Schema(description = "微信分配的小程序ID", required = true)
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
@Schema(description = "随机字符串,不长于32位", required = true)
|
||||||
|
private String nonceStr;
|
||||||
|
|
||||||
|
@Schema(description = "统一下单接口返回的 prepay_id 参数值", required = true)
|
||||||
|
private String packages;
|
||||||
|
|
||||||
|
@Schema(description = "签名类型,默认为MD5,支持HMAC-SHA256和MD5。", required = true)
|
||||||
|
private String signType;
|
||||||
|
|
||||||
|
@Schema(description = "时间戳从1970年1月1日00:00:00至今的秒数,即当前的时间", required = true)
|
||||||
|
private String timeStamp;
|
||||||
|
|
||||||
|
@Schema(description = "支付签名", required = true)
|
||||||
|
private String paySign;
|
||||||
|
|
||||||
|
@Schema(description = "H5支付跳转链接", required = true)
|
||||||
|
private String mwebUrl;
|
||||||
|
|
||||||
|
@Schema(description = "微信商户号", required = true)
|
||||||
|
private String partnerid;
|
||||||
|
|
||||||
|
@Schema(description = "拉起收银台的ticket", required = true)
|
||||||
|
private String ticket;
|
||||||
|
}
|
|
@ -110,8 +110,8 @@ public class StoreOrderController {
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "订单头部数量")
|
@Operation(summary = "订单头部数量")
|
||||||
@RequestMapping(value = "/data", method = RequestMethod.GET)
|
@RequestMapping(value = "/data", method = RequestMethod.GET)
|
||||||
public CommonResult<OrderDataResponse> orderData() {
|
public CommonResult<OrderDataResponse> orderData(String dateLimit, Integer type,String payType) {
|
||||||
return CommonResult.success(orderService.orderData());
|
return CommonResult.success(orderService.orderData(dateLimit, type,payType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package cn.iocoder.yudao.module.shop.convert.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
|
import cn.iocoder.yudao.module.shop.response.order.OrderDetailResponse;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface StoreOrderConvert {
|
||||||
|
|
||||||
|
StoreOrderConvert INSTANCE = Mappers.getMapper(StoreOrderConvert.class);
|
||||||
|
|
||||||
|
List<OrderDetailResponse> convert(List<StoreOrder> list);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package cn.iocoder.yudao.module.shop.convert.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
|
import cn.iocoder.yudao.module.shop.response.order.StoreOrderDetailInfoResponse;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface StoreOrderOneConvert {
|
||||||
|
|
||||||
|
StoreOrderOneConvert INSTANCE = Mappers.getMapper(StoreOrderOneConvert.class);
|
||||||
|
|
||||||
|
StoreOrderDetailInfoResponse convert(StoreOrder storeOrder);
|
||||||
|
|
||||||
|
}
|
|
@ -38,7 +38,7 @@ public class StoreProductReply implements Serializable {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@Schema(description= "用户ID")
|
@Schema(description= "用户ID")
|
||||||
private Integer uid;
|
private Long uid;
|
||||||
|
|
||||||
@Schema(description= "订单ID")
|
@Schema(description= "订单ID")
|
||||||
private Integer oid;
|
private Integer oid;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.iocoder.yudao.module.shop.dal.mysql.order;
|
package cn.iocoder.yudao.module.shop.dal.mysql.order;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
import cn.iocoder.yudao.module.shop.request.order.StoreOrderStaticsticsRequest;
|
import cn.iocoder.yudao.module.shop.request.order.StoreOrderStaticsticsRequest;
|
||||||
import cn.iocoder.yudao.module.shop.response.order.OrderBrokerageData;
|
import cn.iocoder.yudao.module.shop.response.order.OrderBrokerageData;
|
||||||
|
@ -26,7 +27,7 @@ import java.util.List;
|
||||||
* +----------------------------------------------------------------------
|
* +----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface StoreOrderMapper extends BaseMapper<StoreOrder> {
|
public interface StoreOrderMapper extends BaseMapperX<StoreOrder> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单总金额
|
* 订单总金额
|
||||||
|
|
|
@ -2,6 +2,9 @@ package cn.iocoder.yudao.module.shop.service.order;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.StoreOrderPageQueryReqVo;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
import cn.iocoder.yudao.module.shop.request.order.*;
|
import cn.iocoder.yudao.module.shop.request.order.*;
|
||||||
import cn.iocoder.yudao.module.shop.request.product.StoreProductReplyAddRequest;
|
import cn.iocoder.yudao.module.shop.request.product.StoreProductReplyAddRequest;
|
||||||
import cn.iocoder.yudao.module.shop.response.order.*;
|
import cn.iocoder.yudao.module.shop.response.order.*;
|
||||||
|
@ -26,8 +29,6 @@ public interface OrderService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单列表
|
* 订单列表
|
||||||
* @param type 类型
|
|
||||||
* @param pageRequest 分页
|
|
||||||
* @return 订单集合
|
* @return 订单集合
|
||||||
*/
|
*/
|
||||||
PageInfo<OrderDetailResponse> list(Integer type, PageParam pageRequest);
|
PageInfo<OrderDetailResponse> list(Integer type, PageParam pageRequest);
|
||||||
|
@ -42,7 +43,7 @@ public interface OrderService {
|
||||||
* 订单状态数量
|
* 订单状态数量
|
||||||
* @return 订单状态数据量
|
* @return 订单状态数据量
|
||||||
*/
|
*/
|
||||||
OrderDataResponse orderData();
|
OrderDataResponse orderData(String dateLimit, Integer type,String payType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询退款理由
|
* 查询退款理由
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package cn.iocoder.yudao.module.shop.service.order;
|
package cn.iocoder.yudao.module.shop.service.order;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单任务服务 StoreOrderService 接口
|
* 订单任务服务 StoreOrderService 接口
|
||||||
* +----------------------------------------------------------------------
|
* +----------------------------------------------------------------------
|
||||||
|
@ -13,6 +15,7 @@ package cn.iocoder.yudao.module.shop.service.order;
|
||||||
* | Author: CRMEB Team <admin@crmeb.com>
|
* | Author: CRMEB Team <admin@crmeb.com>
|
||||||
* +----------------------------------------------------------------------
|
* +----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@Service
|
||||||
public interface OrderTaskService{
|
public interface OrderTaskService{
|
||||||
|
|
||||||
void cancelByUser();
|
void cancelByUser();
|
||||||
|
|
|
@ -1,13 +1,38 @@
|
||||||
package cn.iocoder.yudao.module.shop.service.order.impl;
|
package cn.iocoder.yudao.module.shop.service.order.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.Constants;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserBillDTO;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.shop.constants.PayConstants;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
import cn.iocoder.yudao.module.shop.request.order.OrderPayRequest;
|
import cn.iocoder.yudao.module.shop.request.order.OrderPayRequest;
|
||||||
import cn.iocoder.yudao.module.shop.response.order.OrderPayResultResponse;
|
import cn.iocoder.yudao.module.shop.response.order.OrderPayResultResponse;
|
||||||
import cn.iocoder.yudao.module.shop.service.order.OrderPayService;
|
import cn.iocoder.yudao.module.shop.service.order.OrderPayService;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.order.StoreOrderStatusService;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.product.StoreProductAttrValueService;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.product.StoreProductService;
|
||||||
|
import cn.iocoder.yudao.module.shop.utils.OrderUtil;
|
||||||
|
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
|
||||||
|
import cn.iocoder.yudao.module.shop.vo.order.WxPayJsResultVo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +52,41 @@ import org.springframework.stereotype.Service;
|
||||||
public class OrderPayServiceImpl implements OrderPayService {
|
public class OrderPayServiceImpl implements OrderPayService {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(OrderPayServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(OrderPayServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderService storeOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderStatusService storeOrderStatusService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderInfoService storeOrderInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberUserApi userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderUtil orderUtil;
|
||||||
|
|
||||||
|
//订单类
|
||||||
|
private StoreOrder order;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreProductService storeProductService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreProductAttrValueService storeProductAttrValueService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiConfigApi apiConfigApi;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付成功处理
|
* 支付成功处理
|
||||||
*
|
*
|
||||||
|
@ -34,7 +94,67 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean paySuccess(StoreOrder storeOrder) {
|
public Boolean paySuccess(StoreOrder storeOrder) {
|
||||||
return null;
|
|
||||||
|
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
|
||||||
|
|
||||||
|
List<MemberUserBillDTO> billList = CollUtil.newArrayList();
|
||||||
|
|
||||||
|
// 订单支付记录
|
||||||
|
// MemberUserBillDTO userBill = userBillInit(storeOrder, user);
|
||||||
|
// billList.add(userBill);
|
||||||
|
|
||||||
|
// 更新用户下单数量
|
||||||
|
// user.setPayCount(user.getPayCount() + 1);
|
||||||
|
|
||||||
|
|
||||||
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
|
//订单日志
|
||||||
|
storeOrderStatusService.createLog(storeOrder.getId(), Constants.ORDER_LOG_PAY_SUCCESS, Constants.ORDER_LOG_MESSAGE_PAY_SUCCESS);
|
||||||
|
|
||||||
|
// 用户信息变更
|
||||||
|
userService.updateById(user);
|
||||||
|
|
||||||
|
return Boolean.TRUE;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (execute) {
|
||||||
|
try {
|
||||||
|
// 发送短信
|
||||||
|
|
||||||
|
// 发送用户支付成功管理员提醒短信
|
||||||
|
|
||||||
|
// 根据配置 打印小票
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("短信、模板通知、优惠券或打印小票异常");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return execute;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 余额支付
|
||||||
|
* @param storeOrder 订单
|
||||||
|
* @return Boolean Boolean
|
||||||
|
*/
|
||||||
|
private Boolean yuePay(StoreOrder storeOrder) {
|
||||||
|
|
||||||
|
// 用户余额扣除
|
||||||
|
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
|
||||||
|
if (ObjectUtil.isNull(user)) throw new ServiceException("用户不存在");
|
||||||
|
storeOrder.setPaid(true);
|
||||||
|
storeOrder.setPayTime(DateUtils.nowDateTime());
|
||||||
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
|
// 订单修改
|
||||||
|
storeOrderService.updateById(storeOrder);
|
||||||
|
// 这里只扣除金额,账单记录在task中处理
|
||||||
|
// 添加支付成功redis队列
|
||||||
|
redisUtil.lPush(Constants.ORDER_TASK_PAY_SUCCESS_AFTER, storeOrder.getOrderId());
|
||||||
|
return Boolean.TRUE;
|
||||||
|
});
|
||||||
|
if (!execute) throw new ServiceException("余额支付订单失败");
|
||||||
|
return execute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +166,154 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public OrderPayResultResponse payment(OrderPayRequest orderPayRequest, String ip) {
|
public OrderPayResultResponse payment(OrderPayRequest orderPayRequest, String ip) {
|
||||||
return null;
|
StoreOrder storeOrder = storeOrderService.getByOderId(orderPayRequest.getOrderNo());
|
||||||
|
if (ObjectUtil.isNull(storeOrder)) {
|
||||||
|
throw new ServiceException("订单不存在");
|
||||||
|
}
|
||||||
|
if (storeOrder.getIsDel()) {
|
||||||
|
throw new ServiceException("订单已被删除");
|
||||||
|
}
|
||||||
|
if (storeOrder.getPaid()) {
|
||||||
|
throw new ServiceException("订单已支付");
|
||||||
|
}
|
||||||
|
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
|
||||||
|
if (ObjectUtil.isNull(user)) throw new ServiceException("用户不存在");
|
||||||
|
|
||||||
|
// 判断订单是否还是之前的支付类型
|
||||||
|
if (!storeOrder.getPayType().equals(orderPayRequest.getPayType())) {
|
||||||
|
// 根据支付类型进行校验,更换支付类型
|
||||||
|
storeOrder.setPayType(orderPayRequest.getPayType());
|
||||||
|
// 余额支付
|
||||||
|
if (orderPayRequest.getPayType().equals(PayConstants.PAY_TYPE_YUE)) {
|
||||||
|
// if (user.getNowMoney().compareTo(storeOrder.getPayPrice()) < 0) {
|
||||||
|
// throw new ServiceException("用户余额不足");
|
||||||
|
// }
|
||||||
|
storeOrder.setIsChannel(3);
|
||||||
|
}
|
||||||
|
if (orderPayRequest.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
||||||
|
switch (orderPayRequest.getPayChannel()){
|
||||||
|
case PayConstants.PAY_CHANNEL_WE_CHAT_H5:// H5
|
||||||
|
storeOrder.setIsChannel(2);
|
||||||
|
break;
|
||||||
|
case PayConstants.PAY_CHANNEL_WE_CHAT_PUBLIC:// 公众号
|
||||||
|
storeOrder.setIsChannel(0);
|
||||||
|
break;
|
||||||
|
case PayConstants.PAY_CHANNEL_WE_CHAT_PROGRAM:// 小程序
|
||||||
|
storeOrder.setIsChannel(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean changePayType = storeOrderService.updateById(storeOrder);
|
||||||
|
if (!changePayType) {
|
||||||
|
throw new ServiceException("变更订单支付类型失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// if (user.getIntegral() < storeOrder.getUseIntegral()) {
|
||||||
|
// throw new ServiceException("用户积分不足");
|
||||||
|
// }
|
||||||
|
|
||||||
|
OrderPayResultResponse response = new OrderPayResultResponse();
|
||||||
|
response.setOrderNo(storeOrder.getOrderId());
|
||||||
|
response.setPayType(storeOrder.getPayType());
|
||||||
|
// 0元付
|
||||||
|
if (storeOrder.getPayPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
Boolean aBoolean = yuePay(storeOrder);
|
||||||
|
response.setPayType(PayConstants.PAY_TYPE_YUE);
|
||||||
|
response.setStatus(aBoolean);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
|
||||||
|
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
||||||
|
// 预下单
|
||||||
|
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip);
|
||||||
|
response.setStatus(true);
|
||||||
|
WxPayJsResultVo vo = new WxPayJsResultVo();
|
||||||
|
vo.setAppId(unifiedorder.get("appId"));
|
||||||
|
vo.setNonceStr(unifiedorder.get("nonceStr"));
|
||||||
|
vo.setPackages(unifiedorder.get("package"));
|
||||||
|
vo.setSignType(unifiedorder.get("signType"));
|
||||||
|
vo.setTimeStamp(unifiedorder.get("timeStamp"));
|
||||||
|
vo.setPaySign(unifiedorder.get("paySign"));
|
||||||
|
if (storeOrder.getIsChannel() == 2) {
|
||||||
|
vo.setMwebUrl(unifiedorder.get("mweb_url"));
|
||||||
|
response.setPayType(PayConstants.PAY_CHANNEL_WE_CHAT_H5);
|
||||||
|
}
|
||||||
|
if (storeOrder.getIsChannel() == 4 || storeOrder.getIsChannel() == 5) {
|
||||||
|
vo.setPartnerid(unifiedorder.get("partnerid"));
|
||||||
|
}
|
||||||
|
// 更新商户订单号
|
||||||
|
storeOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
|
||||||
|
storeOrderService.updateById(storeOrder);
|
||||||
|
response.setJsConfig(vo);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
// 余额支付
|
||||||
|
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_YUE)) {
|
||||||
|
Boolean yueBoolean = yuePay(storeOrder);
|
||||||
|
response.setStatus(yueBoolean);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_OFFLINE)) {
|
||||||
|
throw new ServiceException("暂时不支持线下支付");
|
||||||
|
}
|
||||||
|
response.setStatus(false);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预下单
|
||||||
|
* @param storeOrder 订单
|
||||||
|
* @param ip ip
|
||||||
|
* @return 预下单返回对象
|
||||||
|
*/
|
||||||
|
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip) {
|
||||||
|
// 获取用户openId
|
||||||
|
// 根据订单支付类型来判断获取公众号openId还是小程序openId
|
||||||
|
|
||||||
|
// 获取appid、mch_id
|
||||||
|
// 微信签名key
|
||||||
|
String appId = "";
|
||||||
|
String mchId = "";
|
||||||
|
String signKey = "";
|
||||||
|
if (storeOrder.getIsChannel() == 0) {// 公众号
|
||||||
|
appId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID).toString();
|
||||||
|
mchId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID).toString();
|
||||||
|
signKey = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY).toString();
|
||||||
|
}
|
||||||
|
if (storeOrder.getIsChannel() == 1) {// 小程序
|
||||||
|
appId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_ROUTINE_APP_ID).toString();
|
||||||
|
mchId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_ROUTINE_MCH_ID).toString();
|
||||||
|
signKey = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_ROUTINE_APP_KEY).toString();
|
||||||
|
}
|
||||||
|
if (storeOrder.getIsChannel() == 2) {// H5,使用公众号的
|
||||||
|
appId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_ID).toString();
|
||||||
|
mchId = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_MCH_ID).toString();
|
||||||
|
signKey = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_PAY_WE_CHAT_APP_KEY).toString();
|
||||||
|
}
|
||||||
|
// 获取微信预下单对象
|
||||||
|
//CreateOrderRequestVo unifiedorderVo = getUnifiedorderVo(storeOrder, userToken.getToken(), ip, appId, mchId, signKey);
|
||||||
|
// 预下单(统一下单)
|
||||||
|
//CreateOrderResponseVo responseVo = wechatNewService.payUnifiedorder(unifiedorderVo);
|
||||||
|
// 组装前端预下单参数
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
// map.put("appId", unifiedorderVo.getAppid());
|
||||||
|
// map.put("nonceStr", unifiedorderVo.getAppid());
|
||||||
|
// map.put("package", "prepay_id=".concat(responseVo.getPrepayId()));
|
||||||
|
// map.put("signType", unifiedorderVo.getSign_type());
|
||||||
|
// Long currentTimestamp = WxPayUtil.getCurrentTimestamp();
|
||||||
|
// map.put("timeStamp", Long.toString(currentTimestamp));
|
||||||
|
// String paySign = WxPayUtil.getSign(map, signKey);
|
||||||
|
// map.put("paySign", paySign);
|
||||||
|
// map.put("prepayId", responseVo.getPrepayId());
|
||||||
|
// map.put("prepayTime", DateUtil.nowDateTimeStr());
|
||||||
|
// map.put("outTradeNo", unifiedorderVo.getOut_trade_no());
|
||||||
|
// if (storeOrder.getIsChannel() == 2) {
|
||||||
|
// map.put("mweb_url", responseVo.getMWebUrl());
|
||||||
|
// }
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,28 @@
|
||||||
package cn.iocoder.yudao.module.shop.service.order.impl;
|
package cn.iocoder.yudao.module.shop.service.order.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.shop.service.order.OrderTaskService;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrderStatus;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.product.StoreProductReply;
|
||||||
|
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.Constants;
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.order.*;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.product.StoreProductReplyService;
|
||||||
|
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StoreOrderServiceImpl 接口实现
|
* StoreOrderServiceImpl 接口实现
|
||||||
|
@ -20,27 +38,156 @@ import org.springframework.stereotype.Service;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class OrderTaskServiceImpl implements OrderTaskService {
|
public class OrderTaskServiceImpl implements OrderTaskService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderTaskService storeOrderTaskService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderService storeOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderStatusService storeOrderStatusService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderInfoService storeOrderInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberUserApi userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreProductReplyService storeProductReplyService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TransactionTemplate transactionTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderPayService orderPayService;
|
||||||
//日志
|
//日志
|
||||||
private static final Logger logger = LoggerFactory.getLogger(OrderTaskServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(OrderTaskServiceImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelByUser() {
|
public void cancelByUser() {
|
||||||
|
String redisKey = Constants.ORDER_TASK_REDIS_KEY_AFTER_CANCEL_BY_USER;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.cancelByUser | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object data = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (null == data) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// StoreOrder storeOrder = getJavaBeanStoreOrder(data);
|
||||||
|
StoreOrder storeOrder = storeOrderService.getById(Integer.valueOf(data.toString()));
|
||||||
|
boolean result = storeOrderTaskService.cancelByUser(storeOrder);
|
||||||
|
if (!result) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refundApply() {
|
public void refundApply() {
|
||||||
|
|
||||||
|
String redisKey = Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.refundApply | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object orderId = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (null == orderId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StoreOrder storeOrder = storeOrderService.getById(Integer.valueOf(orderId.toString()));
|
||||||
|
if (ObjectUtil.isNull(storeOrder)) {
|
||||||
|
throw new ServiceException("订单不存在,orderNo = " + orderId);
|
||||||
|
}
|
||||||
|
// boolean result = storeOrderTaskService.refundApply(storeOrder);
|
||||||
|
boolean result = storeOrderTaskService.refundOrder(storeOrder);
|
||||||
|
if (!result) {
|
||||||
|
logger.error("订单退款错误:result = " + result);
|
||||||
|
redisUtil.lPush(redisKey, orderId);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("订单退款错误:" + e.getMessage());
|
||||||
|
redisUtil.lPush(redisKey, orderId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complete() {
|
public void complete() {
|
||||||
|
|
||||||
|
String redisKey = Constants.ORDER_TASK_REDIS_KEY_AFTER_COMPLETE_BY_USER;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.complete | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object data = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (null == data) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StoreOrder storeOrder = getJavaBeanStoreOrder(data);
|
||||||
|
boolean result = storeOrderTaskService.complete(storeOrder);
|
||||||
|
if (!result) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StoreOrder getJavaBeanStoreOrder(Object data) {
|
||||||
|
return JSONUtil.toBean(JSONUtil.parseObj(data.toString()), StoreOrder.class);
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void orderPaySuccessAfter() {
|
public void orderPaySuccessAfter() {
|
||||||
|
String redisKey = Constants.ORDER_TASK_PAY_SUCCESS_AFTER;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.orderPaySuccessAfter | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object data = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (ObjectUtil.isNull(data)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StoreOrder storeOrder = storeOrderService.getByOderId(String.valueOf(data));
|
||||||
|
if (ObjectUtil.isNull(storeOrder)) {
|
||||||
|
logger.error("OrderTaskServiceImpl.orderPaySuccessAfter | 订单不存在,orderNo: " + data);
|
||||||
|
throw new ServiceException("订单不存在,orderNo: " + data);
|
||||||
|
}
|
||||||
|
boolean result = orderPayService.paySuccess(storeOrder);
|
||||||
|
if (!result) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +195,33 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void autoCancel() {
|
public void autoCancel() {
|
||||||
|
String redisKey = Constants.ORDER_AUTO_CANCEL_KEY;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.autoCancel | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object data = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (null == data) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StoreOrder storeOrder = storeOrderService.getByOderId(String.valueOf(data));
|
||||||
|
if (ObjectUtil.isNull(storeOrder)) {
|
||||||
|
logger.error("OrderTaskServiceImpl.autoCancel | 订单不存在,orderNo: " + data);
|
||||||
|
throw new ServiceException("订单不存在,orderNo: " + data);
|
||||||
|
}
|
||||||
|
boolean result = storeOrderTaskService.autoCancel(storeOrder);
|
||||||
|
if (!result) {
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
redisUtil.lPush(redisKey, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +229,27 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void orderReceiving() {
|
public void orderReceiving() {
|
||||||
|
String redisKey = Constants.ORDER_TASK_REDIS_KEY_AFTER_TAKE_BY_USER;
|
||||||
|
Long size = redisUtil.getListSize(redisKey);
|
||||||
|
logger.info("OrderTaskServiceImpl.orderReceiving | size:" + size);
|
||||||
|
if (size < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//如果10秒钟拿不到一个数据,那么退出循环
|
||||||
|
Object id = redisUtil.getRightPop(redisKey, 10L);
|
||||||
|
if (null == id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Boolean result = storeOrderTaskService.orderReceiving(Integer.valueOf(id.toString()));
|
||||||
|
if (!result) {
|
||||||
|
redisUtil.lPush(redisKey, id);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
redisUtil.lPush(redisKey, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +257,84 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void autoComplete() {
|
public void autoComplete() {
|
||||||
|
// 查找所有收获状态订单
|
||||||
|
List<StoreOrder> orderList = storeOrderService.findIdAndUidListByReceipt();
|
||||||
|
if (CollUtil.isEmpty(orderList)) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
logger.info("OrderTaskServiceImpl.autoComplete | size:0");
|
||||||
|
|
||||||
|
// 根据订单状态表判断订单是否可以自动完成
|
||||||
|
for (StoreOrder order : orderList) {
|
||||||
|
StoreOrderStatus orderStatus = storeOrderStatusService.getLastByOrderId(order.getId());
|
||||||
|
if (!orderStatus.getChangeType().equals("user_take_delivery")) {
|
||||||
|
logger.error("订单自动完成:订单记录最后一条不是收货状态,orderId = " + order.getId());
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
// 判断是否到自动完成时间(收货时间向后偏移7天)
|
||||||
|
String comTime = DateUtils.addDay(orderStatus.getCreateTime(), 7, Constants.DATE_FORMAT);
|
||||||
|
int compareDate = DateUtils.compareDate(comTime, DateUtils.nowDateTime(Constants.DATE_FORMAT), Constants.DATE_FORMAT);
|
||||||
|
if (compareDate < 0) {
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ---------------
|
||||||
|
* 自动好评转完成
|
||||||
|
* ---------------
|
||||||
|
*/
|
||||||
|
// 获取订单详情
|
||||||
|
List<StoreOrderInfoOldVo> orderInfoVoList = storeOrderInfoService.getOrderListByOrderId(order.getId());
|
||||||
|
if (CollUtil.isEmpty(orderInfoVoList)) {
|
||||||
|
logger.error("订单自动完成:无订单详情数据,orderId = " + order.getId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<StoreProductReply> replyList = CollUtil.newArrayList();
|
||||||
|
MemberUserRespDTO user = userService.getUser(order.getUid());
|
||||||
|
// 生成评论
|
||||||
|
for (StoreOrderInfoOldVo orderInfo : orderInfoVoList) {
|
||||||
|
// 判断是否已评论
|
||||||
|
if (orderInfo.getInfo().getIsReply().equals(1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String replyType = Constants.STORE_REPLY_TYPE_PRODUCT;
|
||||||
|
// if (ObjectUtil.isNotNull(orderInfo.getInfo().getSeckillId()) && orderInfo.getInfo().getSeckillId() > 0) {
|
||||||
|
// replyType = Constants.STORE_REPLY_TYPE_SECKILL;
|
||||||
|
// }
|
||||||
|
// if (ObjectUtil.isNotNull(orderInfo.getInfo().getBargainId()) && orderInfo.getInfo().getBargainId() > 0) {
|
||||||
|
// replyType = Constants.STORE_REPLY_TYPE_BARGAIN;
|
||||||
|
// }
|
||||||
|
// if (ObjectUtil.isNotNull(orderInfo.getInfo().getCombinationId()) && orderInfo.getInfo().getCombinationId() > 0) {
|
||||||
|
// replyType = Constants.STORE_REPLY_TYPE_PINTUAN;
|
||||||
|
// }
|
||||||
|
StoreProductReply reply = new StoreProductReply();
|
||||||
|
reply.setUid(order.getUid());
|
||||||
|
reply.setOid(order.getId());
|
||||||
|
reply.setProductId(orderInfo.getProductId());
|
||||||
|
reply.setUnique(orderInfo.getUnique());
|
||||||
|
reply.setReplyType(replyType);
|
||||||
|
reply.setProductScore(5);
|
||||||
|
reply.setServiceScore(5);
|
||||||
|
reply.setComment("");
|
||||||
|
reply.setPics("");
|
||||||
|
reply.setNickname(user.getNickname());
|
||||||
|
reply.setAvatar(user.getAvatar());
|
||||||
|
reply.setSku(orderInfo.getInfo().getSku());
|
||||||
|
reply.setCreateTime(DateUtils.nowDateTime());
|
||||||
|
replyList.add(reply);
|
||||||
|
}
|
||||||
|
order.setStatus(Constants.ORDER_STATUS_INT_COMPLETE);
|
||||||
|
Boolean execute = transactionTemplate.execute(e -> {
|
||||||
|
storeOrderService.updateById(order);
|
||||||
|
storeProductReplyService.saveBatch(replyList);
|
||||||
|
return Boolean.TRUE;
|
||||||
|
});
|
||||||
|
if (execute) {
|
||||||
|
redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_COMPLETE_BY_USER, order.getId());
|
||||||
|
} else {
|
||||||
|
logger.error("订单自动完成:更新数据库失败,orderId = " + order.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService {
|
||||||
attrValueService.operationStock(orderInfoVo.getAttrValueId(), orderInfoVo.getPayNum(), "add", Constants.PRODUCT_TYPE_NORMAL);
|
attrValueService.operationStock(orderInfoVo.getAttrValueId(), orderInfoVo.getPayNum(), "add", Constants.PRODUCT_TYPE_NORMAL);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
// throw new CrmebException(e.getMessage());
|
// throw new ServiceException(e.getMessage());
|
||||||
logger.error("回滚库存失败,error = " + e.getMessage());
|
logger.error("回滚库存失败,error = " + e.getMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public interface StoreCartService extends IService<StoreCart> {
|
||||||
* @param uid 用户uid
|
* @param uid 用户uid
|
||||||
* @return StoreCart
|
* @return StoreCart
|
||||||
*/
|
*/
|
||||||
StoreCart getByIdAndUid(Long id, Integer uid);
|
StoreCart getByIdAndUid(Long id, Long uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取购物车商品数量(不区分规格)
|
* 获取购物车商品数量(不区分规格)
|
||||||
|
|
|
@ -300,7 +300,7 @@ public class StoreCartServiceImpl extends ServiceImpl<StoreCartMapper, StoreCart
|
||||||
* @return StoreCart
|
* @return StoreCart
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public StoreCart getByIdAndUid(Long id, Integer uid) {
|
public StoreCart getByIdAndUid(Long id, Long uid) {
|
||||||
LambdaQueryWrapper<StoreCart> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<StoreCart> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(StoreCart::getId, id);
|
lqw.eq(StoreCart::getId, id);
|
||||||
lqw.eq(StoreCart::getUid, uid);
|
lqw.eq(StoreCart::getUid, uid);
|
||||||
|
|
|
@ -403,13 +403,13 @@ public class StoreProductServiceImpl extends ServiceImpl<StoreProductMapper, Sto
|
||||||
}
|
}
|
||||||
// 如果商品是活动商品主商品不允许修改
|
// 如果商品是活动商品主商品不允许修改
|
||||||
// if (storeSeckillService.isExistByProductId(storeProductRequest.getId())) {
|
// if (storeSeckillService.isExistByProductId(storeProductRequest.getId())) {
|
||||||
// throw new CrmebException("商品作为秒杀商品的主商品,需要修改请先删除对应秒杀商品");
|
// throw new ServiceException("商品作为秒杀商品的主商品,需要修改请先删除对应秒杀商品");
|
||||||
// }
|
// }
|
||||||
// if (storeBargainService.isExistByProductId(storeProductRequest.getId())) {
|
// if (storeBargainService.isExistByProductId(storeProductRequest.getId())) {
|
||||||
// throw new CrmebException("商品作为砍价商品的主商品,需要修改请先删除对应砍价商品");
|
// throw new ServiceException("商品作为砍价商品的主商品,需要修改请先删除对应砍价商品");
|
||||||
// }
|
// }
|
||||||
// if (storeCombinationService.isExistByProductId(storeProductRequest.getId())) {
|
// if (storeCombinationService.isExistByProductId(storeProductRequest.getId())) {
|
||||||
// throw new CrmebException("商品作为拼团商品的主商品,需要修改请先删除对应拼团商品");
|
// throw new ServiceException("商品作为拼团商品的主商品,需要修改请先删除对应拼团商品");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
StoreProduct storeProduct = new StoreProduct();
|
StoreProduct storeProduct = new StoreProduct();
|
||||||
|
|
|
@ -3,14 +3,29 @@ package cn.iocoder.yudao.module.shop.utils;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.Constants;
|
import cn.iocoder.yudao.framework.common.enums.Constants;
|
||||||
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
|
||||||
|
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||||
|
import cn.iocoder.yudao.module.shop.constants.PayConstants;
|
||||||
|
import cn.iocoder.yudao.module.shop.constants.SysConfigConstants;
|
||||||
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
|
||||||
|
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OrderUtil {
|
public class OrderUtil {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberUserApi memberUserApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreOrderService storeOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApiConfigApi apiConfigApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* h5 订单查询 where status 封装
|
* h5 订单查询 where status 封装
|
||||||
* @param queryWrapper 查询条件
|
* @param queryWrapper 查询条件
|
||||||
|
@ -63,5 +78,43 @@ public class OrderUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单号查询订单信息
|
||||||
|
* @param id 订单id
|
||||||
|
* @return 计算后的价格集合
|
||||||
|
*/
|
||||||
|
public StoreOrder getInfoById(Integer id) {
|
||||||
|
StoreOrder storeOrder = storeOrderService.getById(id);
|
||||||
|
Long userId = memberUserApi.getUserIdException();
|
||||||
|
|
||||||
|
if(null == storeOrder || !userId.equals(storeOrder.getUid())){
|
||||||
|
//订单号错误
|
||||||
|
throw new ServiceException("没有找到相关订单信息!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return storeOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查支付类型
|
||||||
|
* @param payType 支付类型标识
|
||||||
|
* @return 是否支持
|
||||||
|
*/
|
||||||
|
public Boolean checkPayType(String payType){
|
||||||
|
boolean result = false;
|
||||||
|
payType = payType.toLowerCase();
|
||||||
|
switch (payType){
|
||||||
|
case PayConstants.PAY_TYPE_WE_CHAT:
|
||||||
|
result = apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_PAY_WEIXIN_OPEN).equals("1");
|
||||||
|
break;
|
||||||
|
case PayConstants.PAY_TYPE_YUE:
|
||||||
|
result = (apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_YUE_PAY_STATUS).equals("1"));
|
||||||
|
break;
|
||||||
|
case PayConstants.PAY_TYPE_ALI_PAY:
|
||||||
|
result = (apiConfigApi.getConfigKey(SysConfigConstants.CONFIG_ALI_PAY_STATUS).equals("1"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class TradeOrderServiceTest extends BaseDbUnitTest {
|
||||||
.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()));
|
.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()));
|
||||||
when(productSpuApi.getSpuList(eq(asSet(11L, 21L)))).thenReturn(Arrays.asList(spu01, spu02));
|
when(productSpuApi.getSpuList(eq(asSet(11L, 21L)))).thenReturn(Arrays.asList(spu01, spu02));
|
||||||
// mock 方法(用户收件地址的校验)
|
// mock 方法(用户收件地址的校验)
|
||||||
AddressRespDTO addressRespDTO = new AddressRespDTO().setId(10L).setUserId(userId).setName("芋艿")
|
AddressRespDTO addressRespDTO = new AddressRespDTO().setId(10).setUserId(userId).setName("芋艿")
|
||||||
.setMobile("15601691300").setAreaId(3306L).setPostCode("85757").setDetailAddress("土豆村");
|
.setMobile("15601691300").setAreaId(3306L).setPostCode("85757").setDetailAddress("土豆村");
|
||||||
when(addressApi.getAddress(eq(10L), eq(userId))).thenReturn(addressRespDTO);
|
when(addressApi.getAddress(eq(10L), eq(userId))).thenReturn(addressRespDTO);
|
||||||
// mock 方法(价格计算)
|
// mock 方法(价格计算)
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
<groupId>cn.iocoder.boot</groupId>
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
<artifactId>yudao-common</artifactId>
|
<artifactId>yudao-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-annotation</artifactId>
|
||||||
|
<version>3.5.3.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-annotation</artifactId>
|
||||||
|
<version>3.5.3.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -18,4 +18,13 @@ public interface AddressApi {
|
||||||
*/
|
*/
|
||||||
AddressRespDTO getAddress(Long id, Long userId);
|
AddressRespDTO getAddress(Long id, Long userId);
|
||||||
|
|
||||||
|
|
||||||
|
AddressRespDTO getById(Integer addressId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取默认地址
|
||||||
|
* @return UserAddress
|
||||||
|
*/
|
||||||
|
AddressRespDTO getDefaultByUid(Long uid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class AddressRespDTO {
|
||||||
/**
|
/**
|
||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Integer id;
|
||||||
/**
|
/**
|
||||||
* 用户编号
|
* 用户编号
|
||||||
*/
|
*/
|
||||||
|
@ -45,4 +45,35 @@ public class AddressRespDTO {
|
||||||
*/
|
*/
|
||||||
private Boolean defaulted;
|
private Boolean defaulted;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*收货人所在省
|
||||||
|
*/
|
||||||
|
private String province;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 收货人所在市
|
||||||
|
*/
|
||||||
|
private String city;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 城市id
|
||||||
|
*/
|
||||||
|
private Integer cityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 收货人所在区
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String district;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否删除 0未删除 1删除
|
||||||
|
*
|
||||||
|
* true - 收货人所在区
|
||||||
|
*/
|
||||||
|
private Boolean isDel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,4 +64,16 @@ public interface MemberUserApi {
|
||||||
*/
|
*/
|
||||||
int updateById(MemberUserRespDTO member);
|
int updateById(MemberUserRespDTO member);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户id
|
||||||
|
*
|
||||||
|
* @return Integer
|
||||||
|
*/
|
||||||
|
Long getUserIdException();
|
||||||
|
|
||||||
|
MemberUserRespDTO getInfoException();
|
||||||
|
|
||||||
|
Long getUserId();
|
||||||
|
|
||||||
|
MemberUserRespDTO getInfo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package cn.iocoder.yudao.module.member.api.user.dto;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
/**
|
||||||
|
* 用户账单表
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
* | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
* +----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("eb_user_bill")
|
||||||
|
public class MemberUserBillDTO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*用户账单id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*用户uid
|
||||||
|
*/
|
||||||
|
private Long uid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*关联id
|
||||||
|
*/
|
||||||
|
private String linkId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*0 = 支出 1 = 获得
|
||||||
|
*/
|
||||||
|
private int pm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*账单标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*明细种类
|
||||||
|
*/
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*明细类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*明细数字
|
||||||
|
*/
|
||||||
|
private BigDecimal number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*剩余
|
||||||
|
*/
|
||||||
|
private BigDecimal balance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*备注
|
||||||
|
*/
|
||||||
|
private String mark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*"0 = 带确定 1 = 有效 -1 = 无效"
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*创建时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.member.api.user.dto;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户信息 Response DTO
|
* 用户信息 Response DTO
|
||||||
*
|
*
|
||||||
|
@ -34,4 +36,5 @@ public class MemberUserRespDTO {
|
||||||
*/
|
*/
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,13 @@ package cn.iocoder.yudao.module.member.api.address;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
import cn.iocoder.yudao.module.member.convert.address.AddressConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.address.AddressDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.address.AddressMapper;
|
||||||
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
import cn.iocoder.yudao.module.member.service.address.AddressService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@ -20,9 +26,36 @@ public class AddressApiImpl implements AddressApi {
|
||||||
@Resource
|
@Resource
|
||||||
private AddressService addressService;
|
private AddressService addressService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AddressMapper addressMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AddressConvert addressConvert;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AddressRespDTO getAddress(Long id, Long userId) {
|
public AddressRespDTO getAddress(Long id, Long userId) {
|
||||||
return AddressConvert.INSTANCE.convert02(addressService.getAddress(userId, id));
|
return AddressConvert.INSTANCE.convert02(addressService.getAddress(userId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AddressRespDTO getById(Integer addressId) {
|
||||||
|
LambdaQueryWrapper<AddressDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
lambdaQueryWrapper.eq(AddressDO::getId, addressId);
|
||||||
|
lambdaQueryWrapper.eq(AddressDO::getIsDel, false);
|
||||||
|
return addressConvert.convert02(addressMapper.selectOne(lambdaQueryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取默认地址
|
||||||
|
* @return UserAddress
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AddressRespDTO getDefaultByUid(Long uid) {
|
||||||
|
LambdaQueryWrapper<AddressDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(AddressDO::getDefaulted, true);
|
||||||
|
lambdaQueryWrapper.eq(AddressDO::getId, uid);
|
||||||
|
return addressConvert.convert02(addressMapper.selectOne(lambdaQueryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package cn.iocoder.yudao.module.member.api.user;
|
package cn.iocoder.yudao.module.member.api.user;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.member.convert.user.UserConvert;
|
import cn.iocoder.yudao.module.member.convert.user.UserConvert;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import com.thoughtworks.xstream.core.SecurityUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@ -49,4 +52,63 @@ public class MemberUserApiImpl implements MemberUserApi {
|
||||||
return userService.updateById(UserConvert.INSTANCE.convert3(member));
|
return userService.updateById(UserConvert.INSTANCE.convert3(member));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getUserIdException() {
|
||||||
|
Long id = SecurityFrameworkUtils.getLoginUserId();
|
||||||
|
if (null == id) {
|
||||||
|
throw new ServiceException("登录信息已过期,请重新登录!");
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前用户id
|
||||||
|
*
|
||||||
|
* @return Integer
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-28
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long getUserId() {
|
||||||
|
Long id = SecurityFrameworkUtils.getLoginUserId();
|
||||||
|
if (null == id) {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取个人资料
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-28
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MemberUserRespDTO getInfo() {
|
||||||
|
if (getUserId() == 0L) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return UserConvert.INSTANCE.convert2(userService.getById(getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取个人资料
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
* @author Mr.Zhang
|
||||||
|
* @since 2020-04-28
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MemberUserRespDTO getInfoException() {
|
||||||
|
MemberUserRespDTO user = getInfo();
|
||||||
|
if (user == null) {
|
||||||
|
throw new ServiceException("用户信息不存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.getStatus() == 0) {
|
||||||
|
throw new ServiceException("用户已经被禁用!");
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.member.dal.dataobject.address;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
@ -55,4 +56,10 @@ public class AddressDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Boolean defaulted;
|
private Boolean defaulted;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*是否删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Boolean isDel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue