提交 141eeb5e 作者: 张小凤

Rental(add)

上级 e8106efb
package com.mmc.oms.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
* @Author small @Date 2023/5/27 15:00 @Version 1.0
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// 设置连接超时
factory.setConnectTimeout(15000);
factory.setReadTimeout(5000);
return factory;
}
}
......@@ -2,12 +2,15 @@ package com.mmc.oms.controller;
import com.mmc.oms.common.ResultBody;
import com.mmc.oms.model.dto.OrderInfoDTO;
import com.mmc.oms.model.qo.OrderInfoQO;
import com.mmc.oms.model.vo.LeaseOrderVO;
import com.mmc.oms.service.RentalOrdersService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
/**
* @Author small @Date 2023/5/26 10:49 @Version 1.0
*/
......@@ -32,4 +35,21 @@ public class RentalOrdersController {
@ApiParam(value = "订单编号") @RequestParam(required = true) String orderNo) {
return ResultBody.success(rentalOrdersService.getOrderDetail(orderNo));
}
@ApiOperation(value = "租赁订单-分页-列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderInfoDTO.class)})
@PostMapping("listPcWechatOrder")
public ResultBody listPcWechatOrder(HttpServletRequest request, @RequestBody OrderInfoQO param) {
return ResultBody.success(
// this.getCurrentAccount(request)
rentalOrdersService.listPcOrderInfo(param, null));
}
@ApiOperation(value = "小程序-云仓-订单-分页-列表")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderInfoDTO.class)})
@PostMapping("listPageWechatOrder")
public ResultBody listPageWechatOrder(
HttpServletRequest request, @RequestBody OrderInfoQO param) {
return ResultBody.success(rentalOrdersService.listPageWechatOrder(null, param));
}
}
......@@ -4,8 +4,11 @@ import com.mmc.oms.entity.CouponUserDO;
import com.mmc.oms.entity.OrderInfoDO;
import com.mmc.oms.entity.OrderReceiptDO;
import com.mmc.oms.entity.OrderRefundDO;
import com.mmc.oms.model.qo.OrderInfoQO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author small @Date 2023/5/26 14:47 @Version 1.0
*/
......@@ -22,4 +25,12 @@ public interface RentalOrdersDao {
void insertOrderInfo(OrderInfoDO orderInfo);
void insertOrderReceipt(OrderReceiptDO receipt);
Integer countPcOrderInfo(OrderInfoQO param);
List<OrderInfoDO> listPcOrderInfo(OrderInfoQO param);
int countPageOrderInfo(OrderInfoQO param);
List<OrderInfoDO> listPageOrderInfo(OrderInfoQO param);
}
......@@ -121,6 +121,9 @@ public class OrderInfoDO implements Serializable {
@ApiModelProperty(value = "规格id", example = "1")
private Integer specsId;
@ApiModelProperty(value = "余额", example = "4")
private BigDecimal balance;
/**
* 辅助字段
*
......@@ -165,6 +168,7 @@ public class OrderInfoDO implements Serializable {
.returnTime(this.returnTime)
.couponId(this.couponId)
.specsId(this.specsId)
.balance(this.balance)
.build();
}
......
......@@ -140,6 +140,9 @@ public class OrderInfoDTO implements Serializable {
@ApiModelProperty(value = "规格id", example = "1")
private Integer specsId;
@ApiModelProperty(value = "余额", example = "4")
private BigDecimal balance;
public RepoCashDO buildRepoCashDO() {
return RepoCashDO.builder()
.uid(this.uid)
......
package com.mmc.oms.model.qo;
import com.mmc.oms.common.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @Author small @Date 2023/5/27 15:52 @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
// @ApiModel(value = "com.mmc.csf.model.qo.OrderInfoQO", description = "订单QO")
public class OrderInfoQO implements Serializable {
private static final long serialVersionUID = -3503119623575892302L;
@ApiModelProperty(value = "用户ID", hidden = true)
private Integer repoAccountId;
@ApiModelProperty(value = "关键字")
private String keyword;
@ApiModelProperty(value = "买家账号")
private String buyerAccount;
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "商品id")
private String wareInfoId;
@ApiModelProperty(value = "商品名称")
private String wareTitle;
@ApiModelProperty(value = "订单状态:查字典")
private String tranStatus;
@ApiModelProperty(value = "开始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "用户ID", hidden = true)
private List<Integer> userIds;
@ApiModelProperty(value = "单位ID", hidden = true)
private List<Integer> companys;
@ApiModelProperty(value = "页码", required = true)
@NotNull(
message = "页码不能为空",
groups = {Page.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(
message = "每页显示数不能为空",
groups = {Page.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.oms.service.Impl;
import com.mmc.oms.common.CodeUtil;
import com.mmc.oms.common.ResultBody;
import com.mmc.oms.common.ResultEnum;
import com.mmc.oms.common.TranStatusDic;
import com.mmc.oms.common.*;
import com.mmc.oms.dao.RentalOrdersDao;
import com.mmc.oms.entity.*;
import com.mmc.oms.model.dto.*;
import com.mmc.oms.model.qo.OrderInfoQO;
import com.mmc.oms.model.vo.LeaseOrderVO;
import com.mmc.oms.model.vo.OrderReceiptVO;
import com.mmc.oms.model.vo.PriceAcquisition;
import com.mmc.oms.model.vo.RentalOrderVO;
import com.mmc.oms.service.RentalOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.web.client.RestTemplate;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author small @Date 2023/5/26 10:53 @Version 1.0
......@@ -26,8 +28,7 @@ import java.util.Date;
@Service
public class RentalOrdersServiceImpl implements RentalOrdersService {
// @Autowired
// private RestTemplate restTemplate;
@Autowired private RestTemplate restTemplate;
@Autowired private RentalOrdersDao rentalOrdersDao;
......@@ -50,7 +51,7 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
receipt.setOrderInfoId(orderInfo.getId());
receipt.setCreateTime(cdate);
rentalOrdersDao.insertOrderReceipt(receipt);
orderInfo.setBalance(getRemainingBalance(param.getRepoAccountId()));
OrderInfoDTO dto = orderInfo.buildOrderInfoDTO();
return dto;
......@@ -90,6 +91,23 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
}
/**
* 通过用户id 获取用户剩余的金额
*
* @param repoAccountId
* @return
*/
public BigDecimal getRemainingBalance(Integer repoAccountId) {
ResponseEntity<String> response =
restTemplate.getForEntity(
"http://localhost:8088/payment/repocash/RemainingBalance?repoAccountId="
+ repoAccountId,
String.class);
String body = response.getBody();
BigDecimal bigDecimal = new BigDecimal(body);
return bigDecimal;
}
/**
* 获取渠道等级
*
* @param userId
......@@ -224,4 +242,44 @@ public class RentalOrdersServiceImpl implements RentalOrdersService {
}
return orderInfo;
}
@Override
public PageResult listPcOrderInfo(OrderInfoQO param, BaseAccountDTO cuser) {
if (!cuser.isManage()) {
param.setCompanys(cuser.getCompanyInfo().getCompanys());
}
Integer count = rentalOrdersDao.countPcOrderInfo(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<OrderInfoDTO> data =
rentalOrdersDao.listPcOrderInfo(param).stream()
.map(
d -> {
return d.buildOrderInfoDTO();
})
.collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, data);
}
@Override
public PageResult listPageWechatOrder(BaseAccountDTO account, OrderInfoQO param) {
param.setRepoAccountId(account.getId());
int count = rentalOrdersDao.countPageOrderInfo(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<OrderInfoDTO> data =
rentalOrdersDao.listPageOrderInfo(param).stream()
.map(
d -> {
return d.buildOrderInfoDTO();
})
.collect(Collectors.toList());
return PageResult.buildPage(pageNo, param.getPageSize(), count, data);
}
}
package com.mmc.oms.service;
import com.mmc.oms.common.PageResult;
import com.mmc.oms.common.ResultBody;
import com.mmc.oms.model.dto.BaseAccountDTO;
import com.mmc.oms.model.dto.OrderInfoDTO;
import com.mmc.oms.model.qo.OrderInfoQO;
import com.mmc.oms.model.vo.LeaseOrderVO;
import com.mmc.oms.model.vo.RentalOrderVO;
......@@ -15,4 +17,8 @@ public interface RentalOrdersService {
OrderInfoDTO getOrderDetail(String orderNo);
OrderInfoDTO feignAddLease(LeaseOrderVO param);
PageResult listPcOrderInfo(OrderInfoQO param, BaseAccountDTO cuser);
PageResult listPageWechatOrder(BaseAccountDTO account, OrderInfoQO param);
}
......@@ -199,5 +199,156 @@
#{repoAddress}, #{bookPhone}, #{createTime})
</insert>
<select id="countPcOrderInfo" resultType="java.lang.Integer" parameterType="com.mmc.oms.model.qo.OrderInfoQO">
select count(*)
from order_info o
<where>1=1
<if test=" keyword1 != null and keyword1 != '' ">
and (
o.uid like CONCAT('%',#{keyword1},'%')
or o.buyer_name like CONCAT('%',#{keyword1},'%')
)
</if>
<if test=" keyword2 != null and keyword2 != '' ">
and (
o.order_no like CONCAT('%',#{keyword2},'%')
)
</if>
<if test=" keyword3 != null and keyword3 != '' ">
and (
o.ware_no like CONCAT('%',#{keyword3},'%')
)
</if>
<if test=" keyword4 != null and keyword4 != '' ">
and (
o.ware_title like CONCAT('%',#{keyword4},'%')
)
</if>
<if test=" startTime != null and startTime != '' ">
and o.create_time &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test=" endTime != null and endTime != '' ">
and o.create_time &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test=" tranStatus != null and tranStatus != '' ">
and o.tran_status = #{tranStatus}
</if>
<if test=" userIds != null">
<foreach collection="userIds" item="id" open="and o.repo_account_id in (" close=")" separator=",">
#{id}
</foreach>
</if>
<if test=" companys != null ">
<foreach collection="companys" item="id" open="and o.rcd_company_id in (" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
</select>
<select id="listPcOrderInfo" resultMap="orderInfoResultMap" parameterType="com.mmc.oms.model.qo.OrderInfoQO">
select o.id,o.order_no,o.ware_title,o.sku_title,o.ware_img,o.deposit,
o.unit_price,o.ware_num,o.buyer_name,o.buyer_phone,o.uid,o.remark,
o.tran_status,o.should_pay,o.actual_pay,o.pf_remark,o.create_time,o.ware_no,
rp.order_info_id,rp.receipt_method,rp.take_name,
rp.take_phone,rp.region,rp.detail_address,rp.repo_name,rp.repo_address,
rp.book_phone,rp.send_ex_code,rp.send_ex_no,rp.send_address,rp.ren_method,
rp.ren_phone,rp.ren_name,rp.ren_ex_code,rp.ren_ex_no,rp.ren_address,rp.ren_repo_name,
rp.ren_repo_addr,rp.ren_repo_phone
from order_info o
inner join order_receipt rp on rp.order_info_id=o.id
<where>1=1
<if test=" keyword1 != null and keyword1 != '' ">
and (
o.uid like CONCAT('%',#{keyword1},'%')
or o.buyer_name like CONCAT('%',#{keyword1},'%')
)
</if>
<if test=" keyword2 != null and keyword2 != '' ">
and (
o.order_no like CONCAT('%',#{keyword2},'%')
)
</if>
<if test=" keyword3 != null and keyword3 != '' ">
and (
o.ware_no like CONCAT('%',#{keyword3},'%')
)
</if>
<if test=" keyword4 != null and keyword4 != '' ">
and (
o.ware_title like CONCAT('%',#{keyword4},'%')
)
</if>
<if test=" startTime != null and startTime != '' ">
and o.create_time &gt;= STR_TO_DATE(#{startTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test=" endTime != null and endTime != '' ">
and o.create_time &lt;= STR_TO_DATE(#{endTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test=" tranStatus != null and tranStatus != '' ">
and o.tran_status = #{tranStatus}
</if>
<if test=" userIds != null">
<foreach collection="userIds" item="id" open="and o.repo_account_id in (" close=")" separator=",">
#{id}
</foreach>
</if>
<if test=" companys != null ">
<foreach collection="companys" item="id" open="and o.rcd_company_id in (" close=")" separator=",">
#{id}
</foreach>
</if>
</where>
order by o.create_time DESC
limit #{pageNo},#{pageSize}
</select>
<select id="countPageOrderInfo" resultType="java.lang.Integer" parameterType="com.mmc.oms.model.qo.OrderInfoQO">
select count(*)
from order_info o
<where>
o.repo_account_id = #{repoAccountId}
<if test=" tranStatus!=null and tranStatus!='' ">
and o.tran_status = #{tranStatus}
</if>
<if test=" keyword!=null and keyword!='' ">
and (
o.ware_title like CONCAT('%',#{keyword},'%')
or o.order_no like CONCAT('%',#{keyword},'%')
)
</if>
</where>
</select>
<select id="listPageOrderInfo" resultMap="orderInfoResultMap" parameterType="com.mmc.oms.model.qo.OrderInfoQO">
select o.id,o.order_no,o.ware_title,o.ware_img,o.sku_title,o.tran_status,
o.ware_num,o.should_pay,o.actual_pay,
rp.order_info_id,rp.receipt_method,rp.take_name,
rp.take_phone,rp.region,rp.detail_address,rp.repo_name,rp.repo_address,
rp.book_phone,rp.send_ex_code,rp.send_ex_no,rp.send_address,rp.ren_method,
rp.ren_phone,rp.ren_name,rp.ren_ex_code,rp.ren_ex_no,rp.ren_address,rp.ren_repo_name,
rp.ren_repo_addr,rp.ren_repo_phone
from order_info o
inner join order_receipt rp on rp.order_info_id=o.id
<where>
o.repo_account_id = #{repoAccountId}
<if test=" tranStatus!=null and tranStatus!='' ">
and o.tran_status = #{tranStatus}
</if>
<if test=" keyword!=null and keyword!='' ">
and (
o.ware_title like CONCAT('%',#{keyword},'%')
or o.order_no like CONCAT('%',#{keyword},'%')
)
</if>
</where>
order by o.create_time DESC
limit #{pageNo},#{pageSize}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论