Browse Source

我的账单

fllmoyu 4 năm trước cách đây
mục cha
commit
022775acee

+ 42 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/OrderDetailDTO.java

@@ -0,0 +1,42 @@
+package com.jpsoft.enterprise.modules.base.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-2-23 10:02
+ */
+@Data
+public class OrderDetailDTO {
+
+    private String id;
+
+    private String billDetailId;
+
+    private String billName;
+
+    private String companyName;
+
+    private BigDecimal totalFee;
+
+    private String billRemark;
+
+    private String billDetail;
+
+    private Integer payStatus;
+
+    private String payName;
+
+    private String outOrderNo;
+
+    @ApiModelProperty(value = "支付时间")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    private Date payTime;
+}

+ 47 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/OrderListDTO.java

@@ -0,0 +1,47 @@
+package com.jpsoft.enterprise.modules.base.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-2-23 9:03
+ */
+@Data
+public class OrderListDTO {
+
+    private String id;
+
+    private String billName;
+
+    private BigDecimal totalFee;
+
+    private Integer payStatus;
+
+    private String payStatusStr;
+
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    public String getPayStatusStr() {
+        if (payStatus.equals(10)){
+            return "未支付";
+        }
+        else if (payStatus.equals(20)){
+            return "已支付";
+        }
+        else if (payStatus.equals(30)){
+            return "已关闭";
+        }
+        else{
+            return "已退款";
+        }
+    }
+}

+ 13 - 3
common/src/main/resources/mapper/base/BillDetailInfo.xml

@@ -97,14 +97,24 @@
     <select id="search" parameterType="hashmap" resultMap="BillDetailInfoMap">
         <![CDATA[
 			SELECT
-				*
+				a.*
 			FROM
 				base_bill_detail_info a
+				left join base_bill_info b on b.id_ = a.bill_id
+				left join base_order_info c on c.id_ = a.order_id
 		]]>
         <where>
-            del_flag = 0
+            a.del_flag = 0
+            and b.del_flag = 0
+            and c.del_flag = 0
             <if test="searchParams.id != null">
-                and ID_ like #{searchParams.id}
+                and a.ID_ like #{searchParams.id}
+            </if>
+            <if test="searchParams.companyId != null ">
+                and a.company_id = #{searchParams.companyId}
+            </if>
+            <if test="searchParams.status != null">
+                and b.status_ = #{searchParams.status}
             </if>
         </where>
         <foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 150 - 2
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/OrderInfoApiController.java

@@ -1,8 +1,26 @@
 package com.jpsoft.enterprise.modules.mobile.controller;
 
+import cn.hutool.core.date.DateUtil;
+import com.github.pagehelper.Page;
+import com.jpsoft.enterprise.modules.base.dto.*;
+import com.jpsoft.enterprise.modules.base.entity.*;
+import com.jpsoft.enterprise.modules.base.service.*;
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
+import com.jpsoft.enterprise.modules.common.dto.Sort;
+import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author 墨鱼_mo
@@ -14,4 +32,134 @@ import org.springframework.web.bind.annotation.RestController;
 public class OrderInfoApiController {
 
 
+    @Autowired
+    private OrderInfoService orderInfoService;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @Autowired
+    private PersonInfoService personInfoService;
+
+    @Autowired
+    private BillInfoService billInfoService;
+
+    @Autowired
+    private BillDetailInfoService billDetailInfoService;
+
+    @PostMapping("orderList")
+    @ApiOperation(value = "订单列表")
+    public MessageResult<Map> orderList(
+            String token,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="10") int pageSize,
+            @RequestAttribute String subject) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            //查询人
+            PersonInfo personInfo = personInfoService.get(subject);
+            if (personInfo == null){
+                throw new Exception("个人信息有误");
+            }
+
+            List<OrderListDTO> list = new ArrayList<>();
+            CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("companyId",companyInfo.getId());
+            searchParams.put("status","1");
+
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.create_time", "desc"));
+            sortList.add(new Sort("c.pay_status","asc"));
+
+            Page<BillDetailInfo> page = billDetailInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+
+            List<BillDetailInfo> billDetailInfoList = page.getResult();
+            if (billDetailInfoList.size()>0){
+                for (BillDetailInfo billDetailInfo : billDetailInfoList){
+                    BillInfo billInfo = billInfoService.get(billDetailInfo.getBillId());
+                    OrderInfo orderInfo = orderInfoService.get(billDetailInfo.getOrderId());
+                    OrderListDTO orderListDTO = new OrderListDTO();
+
+                    orderListDTO.setId(billDetailInfo.getId());
+                    orderListDTO.setBillName(billInfo.getBillName());
+                    orderListDTO.setPayStatus(orderInfo.getPayStatus());
+                    orderListDTO.setPayStatusStr(orderListDTO.getPayStatusStr());
+                    orderListDTO.setTotalFee(orderInfo.getTotalFee());
+                    orderListDTO.setCreateTime(orderInfo.getCreateTime());
+                    list.add(orderListDTO);
+                }
+
+            }
+
+            Map<String, Object> pageMap = new HashMap<>();
+            pageMap.put("recordsTotal", page.getTotal());
+            pageMap.put("recordsFiltered", page.getTotal());
+            pageMap.put("totalPage", page.getPages());
+            pageMap.put("pageNumber", page.getPageNum());
+            pageMap.put("pageSize", page.getPageSize());
+            pageMap.put("data", list);
+
+            messageResult.setData(pageMap);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+    @PostMapping("orderDetail")
+    @ApiOperation(value = "账单详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form")
+    })
+    public MessageResult<OrderDetailDTO> orderDetail(String id, String token, @RequestAttribute String subject) {
+        MessageResult<OrderDetailDTO> messageResult = new MessageResult<>();
+
+        try {
+
+            BillDetailInfo billDetailInfo = billDetailInfoService.get(id);
+            if (billDetailInfo == null){
+                throw new Exception("记录不存在");
+            }
+            BillInfo billInfo = billInfoService.get(billDetailInfo.getBillId());
+            OrderInfo orderInfo = orderInfoService.get(billDetailInfo.getOrderId());
+            CompanyInfo companyInfo = companyInfoService.get(billDetailInfo.getCompanyId());
+            OrderDetailDTO orderDetailDTO = new OrderDetailDTO();
+            orderDetailDTO.setId(orderInfo.getId());
+            orderDetailDTO.setBillDetailId(billDetailInfo.getId());
+            orderDetailDTO.setBillName(billInfo.getBillName());
+            orderDetailDTO.setCompanyName(companyInfo.getCompanyName());
+            orderDetailDTO.setTotalFee(orderInfo.getTotalFee());
+            orderDetailDTO.setBillRemark(billInfo.getBillRemark());
+            orderDetailDTO.setBillDetail(billDetailInfo.getBillDetail());
+            orderDetailDTO.setPayStatus(orderInfo.getPayStatus());
+            orderDetailDTO.setPayName(orderInfo.getPayName());
+            orderDetailDTO.setOutOrderNo(orderInfo.getOutOrderNo());
+            orderDetailDTO.setPayTime(orderInfo.getPayTime());
+
+            messageResult.setData(orderDetailDTO);
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+
+
 }