zhang song 6 år sedan
förälder
incheckning
260b5db33e

+ 54 - 0
db/koi.sql

@@ -17,6 +17,60 @@
  Date: 18/04/2019 19:59:57
 */
 
+/**
+
+
+
+
+SELECT
+	concat( '\t', ls_order.order_code ) AS 订单编号,
+	concat( '\t', ls_order.bill_no ) AS 银联单号,
+	concat( '\t', ls_customer.username ) AS 注册账号,
+	ls_order_attr.receipt_name AS 购车人,
+	concat( '\t', ls_order_attr.receipt_mobile ) AS 购车人电话,
+	ls_order_attr.receipt_address AS 收货地址,
+	ls_order_attr.receipt_detail_address AS 详细地址,
+	ls_order_sku.sku_name AS 商品名称,
+	ls_order.create_time AS 下单时间,
+	CASE	WHEN ls_order.status = '1' THEN
+		'待付款'
+		WHEN ls_order.status = '2' THEN
+		'待发货'
+		WHEN ls_order.status = '3' THEN
+		'待收货'
+		WHEN ls_order.status = '4' THEN
+		'已完成'
+		WHEN ls_order.status = '5' THEN
+		'取消订单'
+		WHEN ls_order.status = '6' THEN
+		'退款通过'
+		WHEN ls_order.status = '7' THEN
+		'退货通过' ELSE '异常'
+	END
+	 AS 订单状态,
+	ls_order.original_price AS 实付金额,
+		CASE	WHEN ls_order.source = '1' THEN
+		'pc'
+		WHEN ls_order.source = '2' THEN
+		'h5'
+		WHEN ls_order.source = '3' THEN
+		'app'
+	 ELSE '异常'
+	END
+	 AS 来源
+FROM
+	ls_order
+	JOIN ls_customer ON ls_order.customer_id = ls_customer.id
+	JOIN ls_order_attr ON ls_order_attr.order_id = ls_order.id
+	JOIN ls_order_sku ON ls_order_sku.order_id = ls_order.id
+WHERE
+	ls_customer.del_flag = '0'
+	AND ls_order.store_id = 0
+ORDER BY
+	ls_order.id DESC
+
+
+ */
 SET NAMES utf8mb4;
 SET FOREIGN_KEY_CHECKS = 0;
 

+ 43 - 3
pine-admin/src/main/java/com/pine/admin/modules/business/controller/OrderController.java

@@ -1,12 +1,13 @@
 package com.pine.admin.modules.business.controller;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import com.pine.common.dto.Page;
 import com.pine.admin.modules.base.binder.BaseController;
 import com.pine.common.dto.Result;
+import com.pine.common.excelutil.ExcelPoiUtil;
+import com.pine.common.exception.ApiException;
+import com.pine.common.utils.DateTimeTool;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import com.pine.admin.modules.business.entity.Order;
 import com.pine.admin.modules.business.service.OrderService;
 
+import javax.servlet.http.HttpServletResponse;
+
 
 /**
  * 订单表
@@ -59,5 +62,42 @@ public class OrderController extends BaseController {
         return Result.success(true, result);
     }
 
+        /**
+     * <p>excel。</p>
+     */
+    @ApiOperation(value = "分页获取订单表数据", notes = "根据条件获取")
+    @RequestMapping(value = "/excel", method = RequestMethod.GET)
+    public void excel( HttpServletResponse response) {
+
+        List<Order> allList = orderService.getAllList(null);
+        allList.stream().forEach(o ->{
+            orderService.FullOrderInfo(o);
+            o.setShopName(o.getOrderSkus().get(0).getSkuName());
+        });
+        try {
+            List<Object> exchangeCodes = new ArrayList<>();
+            if (!exchangeCodes.isEmpty()) {
+                String excelName = "商城全部订单" ;
+                LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
+                fieldMap.put("orderCode", "订单号");
+                fieldMap.put("billNo", "银联单号");
+                fieldMap.put("customerName", "注册账号");
+                fieldMap.put("receiptName", "购车人");
+                fieldMap.put("receiptMobile", "购车人电话");
+                fieldMap.put("receiptMobile", "购车人电话");
+                fieldMap.put("address", "收货地址");
+                fieldMap.put("shopName", "商品名称");
+                fieldMap.put("createTime", "下单时间");
+                fieldMap.put("status", "订单状态");
+                fieldMap.put("originalPrice", "实付金额");
+                fieldMap.put("source", "来源");
+                ExcelPoiUtil.export(excelName, exchangeCodes, fieldMap, response);
+            }
+        } catch (Exception e) {
+
+            throw new ApiException(e.getMessage());
+        }
+    }
+
 
 }

+ 8 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/entity/Order.java

@@ -404,4 +404,12 @@ public class Order implements Serializable {
      * 收货人地址
      */
     private String address;
+    /**
+     * 商品名称
+     */
+    private String shopName;
+    /**
+     * billNo 银联单号
+     */
+    private String billNo;
 }

+ 2 - 2
pine-admin/src/main/java/com/pine/admin/modules/business/service/impl/CarOrderServiceImpl.java

@@ -60,7 +60,7 @@ public class CarOrderServiceImpl implements CarOrderService {
     public List<CarOrder> getBackByPage(Page page, CarOrder record) {
         log.info("getBackByPage");
         try {
-            if (!ShiroUtils.getShiroUserInfo().getName().contains("超级管理员")) {
+            if (!ShiroUtils.getShiroUserInfo().getName().contains("商城管理员")) {
                 record.setCarSupplier(ShiroUtils.getShiroUserInfo().getName());
             }
             Map<String, Object> parameter = new HashMap<String, Object>();
@@ -86,7 +86,7 @@ public class CarOrderServiceImpl implements CarOrderService {
 
             // 首付/尾款支付状态查询
 
-            if (!ShiroUtils.getShiroUserInfo().getName().contains("超级管理员")) {
+            if (!ShiroUtils.getShiroUserInfo().getName().contains("商城管理员")) {
                 record.setCarSupplier(ShiroUtils.getShiroUserInfo().getName());
             }
             Map<String, Object> parameter = new HashMap<String, Object>();

+ 2 - 2
pine-admin/src/main/java/com/pine/admin/modules/business/service/impl/OrderServiceImpl.java

@@ -61,7 +61,7 @@ public class OrderServiceImpl implements OrderService {
 
         log.info("getOrderByPage");
         try {
-            if (!ShiroUtils.getShiroUserInfo().getName().contains("超级管理员")) {
+            if (!ShiroUtils.getShiroUserInfo().getName().contains("商城管理员")) {
                 record.setDealerId(ShiroUtils.getShiroUserInfo().getDealerID());
             }
             Map<String, Object> parameter = new HashMap<String, Object>();
@@ -83,7 +83,7 @@ public class OrderServiceImpl implements OrderService {
         try {
 
             Order order = orderDao.getById(Long.valueOf(id));
-            if (!ShiroUtils.getShiroUserInfo().getName().contains("超级管理员")) {
+            if (!ShiroUtils.getShiroUserInfo().getName().contains("商城管理员")) {
                if (!order.getDealerId().equals(ShiroUtils.getShiroUserInfo().getDealerID())){
                    throw new ApiException("无权限查看");
                }

+ 10 - 9
pine-admin/src/main/java/com/pine/admin/modules/system/service/impl/SysServiceImpl.java

@@ -96,30 +96,31 @@ public class SysServiceImpl implements SysService {
     }
 
     @Override
-    public String decryptUser(String ip,String casualBacking) {
+    public String decryptUser(String ip, String casualBacking) {
 
         String responseString = RSAUtils.changeSpecialToString(casualBacking);
 
-         ip ="127.0.0.1";
+//        ip = "127.0.0.1";
         if (StringUtils.isEmpty(responseString)) {
             log.error("offlineAudit fail due to rsa decrypt fail");
             throw new ApiException("秘钥解析失败");
         }
-        String redisKey = ip +"+" + responseString;
-
-
+        String redisKey = ip + "+" + responseString;
+        log.info("免密登录key:{}"+redisKey);
+        //获取登录信息
         Object o = redisService.get(redisKey);
 
 
-        if (ObjectUtils.isEmpty(o)){
+        if (ObjectUtils.isEmpty(o)) {
             throw new ApiException("用户未登录");
         }
 
         String dealerInfo = String.valueOf(o);
-
+        //删除密钥
+        redisService.remove(redisKey);
         ShiroUserInfo userInfo = JSONObject.parseObject(dealerInfo, ShiroUserInfo.class);
 
-        if (!userInfo.getAccount().equals(responseString)){
+        if (!userInfo.getAccount().equals(responseString)) {
             throw new ApiException("非法操作");
         }
 
@@ -163,7 +164,7 @@ public class SysServiceImpl implements SysService {
             }
             return dealerOpenIdToken;
 
-        }catch (Exception e){
+        } catch (Exception e) {
             throw new ApiException(e.getMessage());
         }
     }

+ 1 - 1
pine-admin/src/main/resources/application.properties

@@ -16,6 +16,6 @@ mybatis.typeAliasesPackage:com.pine.admin.*.entity
 mybatis.configuration.mapUnderscoreToCamelCase=true
 #ÈÕÖ¾´òÓ¡SQL
 logging.level.com.pine=DEBUG
-logging.path=/home/INFO_FILE.%d{yyyy-MM-dd}.gz
+logging.path=/home/dealer.gz
 logging.level.com.pine.admin.modules.system.dao=DEBUG
 

+ 2 - 2
pine-admin/src/main/resources/mapper/business/CarOrderDao.xml

@@ -391,13 +391,13 @@
             <if test="record.offlinePayType == 2">
                 and status = 3
             </if>
---             and loan_status != 2
+            -- and loan_status != 2
             and status != 1
         </where>
         order by id desc
     </select>
     <!-- 查询退订订单  -->
-    <select id="queryBackByPage" parameterType="java.util.Map"  resultMap="offlinePayments">
+    <select id="queryBackByPage" parameterType="java.util.Map" resultMap="offlinePayments">
         select lco.*, lcbo.status backStatus from ls_car_order lco JOIN ls_car_back_order lcbo on lco.`code` =
         lcbo.order_code
         <where>

+ 70 - 185
pine-admin/src/main/resources/mapper/business/OrderDao.xml

@@ -400,192 +400,77 @@
     </select>
 
     <!-- 全部查询 -->
-    <select id="queryAll" parameterType="java.util.Map"
-            resultMap="entityMap">
-        select
-        <include refid="Base_Column_List"/>
+    <select id="queryAll"  parameterType="java.util.Map"
+            resultType="com.pine.admin.modules.business.entity.Order">
+        select ls_order.*,
+        ls_customer.username as customerName,
+        ls_customer.mobile,
+        ls_order_attr.receipt_mobile as receiptMobile,
+        ls_order_attr.receipt_name as receiptName,
+        concat(ls_order_attr.receipt_address,ls_order_attr.receipt_detail_address) as address
         from ls_order
-        <where>
-            and del_flag = 'N'
-            <if test="id != null and !&quot;&quot;.equals(id)">
-                and id = #{id}
-            </if>
-            <if test="orderCode != null and !&quot;&quot;.equals(orderCode)">
-                and order_code = #{orderCode}
-            </if>
-            <if test="masterOrderCode != null and !&quot;&quot;.equals(masterOrderCode)">
-                and master_order_code = #{masterOrderCode}
-            </if>
-            <if test="customerId != null and !&quot;&quot;.equals(customerId)">
-                and customer_id = #{customerId}
-            </if>
-            <if test="price != null and !&quot;&quot;.equals(price)">
-                and price = #{price}
-            </if>
-            <if test="presalePrice != null and !&quot;&quot;.equals(presalePrice)">
-                and presale_price = #{presalePrice}
-            </if>
-            <if test="originalPrice != null and !&quot;&quot;.equals(originalPrice)">
-                and original_price = #{originalPrice}
-            </if>
-            <if test="freightPrice != null and !&quot;&quot;.equals(freightPrice)">
-                and freight_price = #{freightPrice}
-            </if>
-            <if test="modifyPrice != null and !&quot;&quot;.equals(modifyPrice)">
-                and modify_price = #{modifyPrice}
-            </if>
-            <if test="pointPrice != null and !&quot;&quot;.equals(pointPrice)">
-                and point_price = #{pointPrice}
-            </if>
-            <if test="couponPrice != null and !&quot;&quot;.equals(couponPrice)">
-                and coupon_price = #{couponPrice}
-            </if>
-            <if test="redEnvelopePrice != null and !&quot;&quot;.equals(redEnvelopePrice)">
-                and red_envelope_price = #{redEnvelopePrice}
-            </if>
-            <if test="concessionalRate != null and !&quot;&quot;.equals(concessionalRate)">
-                and concessional_rate = #{concessionalRate}
-            </if>
-            <if test="status != null and !&quot;&quot;.equals(status)">
-                and status = #{status}
-            </if>
-            <if test="presaleStatus != null and !&quot;&quot;.equals(presaleStatus)">
-                and presale_status = #{presaleStatus}
-            </if>
-            <if test="evaluationStatus != null and !&quot;&quot;.equals(evaluationStatus)">
-                and evaluation_status = #{evaluationStatus}
-            </if>
-            <if test="redEnvelopeCode != null and !&quot;&quot;.equals(redEnvelopeCode)">
-                and red_envelope_code = #{redEnvelopeCode}
-            </if>
-            <if test="couponNo != null and !&quot;&quot;.equals(couponNo)">
-                and coupon_no = #{couponNo}
-            </if>
-            <if test="usePoint != null and !&quot;&quot;.equals(usePoint)">
-                and use_point = #{usePoint}
-            </if>
-            <if test="payType != null and !&quot;&quot;.equals(payType)">
-                and pay_type = #{payType}
-            </if>
-            <if test="storeId != null and !&quot;&quot;.equals(storeId)">
-                and store_id = #{storeId}
-            </if>
-            <if test="cancelReson != null and !&quot;&quot;.equals(cancelReson)">
-                and cancel_reson = #{cancelReson}
-            </if>
-            <if test="predepositPay != null and !&quot;&quot;.equals(predepositPay)">
-                and predeposit_pay = #{predepositPay}
-            </if>
-            <if test="source != null and !&quot;&quot;.equals(source)">
-                and source = #{source}
-            </if>
-            <if test="freightTemplateId != null and !&quot;&quot;.equals(freightTemplateId)">
-                and freight_template_id = #{freightTemplateId}
-            </if>
-            <if test="waybillCode != null and !&quot;&quot;.equals(waybillCode)">
-                and waybill_code = #{waybillCode}
-            </if>
-            <if test="orderType != null and !&quot;&quot;.equals(orderType)">
-                and order_type = #{orderType}
-            </if>
-            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
-                and create_time = #{createTime}
-            </if>
-            <if test="payTime != null and !&quot;&quot;.equals(payTime)">
-                and pay_time = #{payTime}
-            </if>
-            <if test="deliveryTime != null and !&quot;&quot;.equals(deliveryTime)">
-                and delivery_time = #{deliveryTime}
-            </if>
-            <if test="receivingTime != null and !&quot;&quot;.equals(receivingTime)">
-                and receiving_time = #{receivingTime}
-            </if>
-            <if test="cancelTime != null and !&quot;&quot;.equals(cancelTime)">
-                and cancel_time = #{cancelTime}
-            </if>
-            <if test="modifyTime != null and !&quot;&quot;.equals(modifyTime)">
-                and modify_time = #{modifyTime}
-            </if>
-            <if test="evaluationTime != null and !&quot;&quot;.equals(evaluationTime)">
-                and evaluation_time = #{evaluationTime}
-            </if>
-            <if test="presaleTime != null and !&quot;&quot;.equals(presaleTime)">
-                and presale_time = #{presaleTime}
-            </if>
-            <if test="groupHead != null and !&quot;&quot;.equals(groupHead)">
-                and group_head = #{groupHead}
-            </if>
-            <if test="groupId != null and !&quot;&quot;.equals(groupId)">
-                and group_id = #{groupId}
-            </if>
-            <if test="groupMarketingId != null and !&quot;&quot;.equals(groupMarketingId)">
-                and group_marketing_id = #{groupMarketingId}
-            </if>
-            <if test="groupSkuId != null and !&quot;&quot;.equals(groupSkuId)">
-                and group_sku_id = #{groupSkuId}
-            </if>
-            <if test="groupStatus != null and !&quot;&quot;.equals(groupStatus)">
-                and group_status = #{groupStatus}
-            </if>
-            <if test="groupNum != null and !&quot;&quot;.equals(groupNum)">
-                and group_num = #{groupNum}
-            </if>
-            <if test="openGroupTime != null and !&quot;&quot;.equals(openGroupTime)">
-                and open_group_time = #{openGroupTime}
-            </if>
-            <if test="autoHandleStatus != null and !&quot;&quot;.equals(autoHandleStatus)">
-                and auto_handle_status = #{autoHandleStatus}
-            </if>
-            <if test="recommended != null and !&quot;&quot;.equals(recommended)">
-                and recommended = #{recommended}
-            </if>
-            <if test="crowdfundingId != null and !&quot;&quot;.equals(crowdfundingId)">
-                and crowdfunding_id = #{crowdfundingId}
-            </if>
-            <if test="lotteryStatus != null and !&quot;&quot;.equals(lotteryStatus)">
-                and lottery_status = #{lotteryStatus}
-            </if>
-            <if test="writeOffCode != null and !&quot;&quot;.equals(writeOffCode)">
-                and write_off_code = #{writeOffCode}
-            </if>
-            <if test="communityBuyCustomerId != null and !&quot;&quot;.equals(communityBuyCustomerId)">
-                and community_buy_customer_id = #{communityBuyCustomerId}
-            </if>
-            <if test="communityBuyId != null and !&quot;&quot;.equals(communityBuyId)">
-                and community_buy_id = #{communityBuyId}
-            </if>
-            <if test="profit != null and !&quot;&quot;.equals(profit)">
-                and profit = #{profit}
-            </if>
-            <if test="communityName != null and !&quot;&quot;.equals(communityName)">
-                and community_name = #{communityName}
-            </if>
-            <if test="communityBuyName != null and !&quot;&quot;.equals(communityBuyName)">
-                and community_buy_name = #{communityBuyName}
-            </if>
-            <if test="billNo != null and !&quot;&quot;.equals(billNo)">
-                and bill_no = #{billNo}
-            </if>
-            <if test="dealerId != null and !&quot;&quot;.equals(dealerId)">
-                and dealer_id = #{dealerId}
-            </if>
-            <if test="dealerInfo != null and !&quot;&quot;.equals(dealerInfo)">
-                and dealer_info = #{dealerInfo}
-            </if>
-            <if test="payChannel != null and !&quot;&quot;.equals(payChannel)">
-                and pay_channel = #{payChannel}
-            </if>
-            <if test="skuType != null and !&quot;&quot;.equals(skuType)">
-                and sku_type = #{skuType}
-            </if>
-            <if test="jetourSendFlag != null and !&quot;&quot;.equals(jetourSendFlag)">
-                and jetour_send_flag = #{jetourSendFlag}
-            </if>
-            <if test="incomingUrl != null and !&quot;&quot;.equals(incomingUrl)">
-                and incoming_url = #{incomingUrl}
-            </if>
-        </where>
-        order by id desc
+        join ls_customer on ls_order.customer_id = ls_customer.id
+        join ls_order_attr on ls_order_attr.order_id = ls_order.id
+        where ls_customer.del_flag = '0'
+        and ls_order.store_id = 0
+        and ls_order.status != 1
+        and ls_order.status != 5
+        <!-- 收货人手机号 -->
+        <if test="receiptMobile != null and receiptMobile != '' ">
+            and ls_order_attr.receipt_mobile = #{receiptMobile}
+        </if>
+        <!-- 收货人姓名 -->
+        <if test="receiptName != null and receiptName != '' ">
+            and ls_order_attr.receipt_name like CONCAT(CONCAT('%', #{receiptName}),'%')
+        </if>
+        <if test="orderCode != null and orderCode != '' ">
+            AND ls_order.order_code = #{orderCode}
+        </if>
+        <if test="customerName != null and customerName != ''">
+            AND ls_customer.username like CONCAT(CONCAT('%', #{customerName}),'%')
+        </if>
+        <if test="customerMobile != null and customerMobile != ''">
+            AND ls_customer.mobile = #{customerMobile}
+        </if>
+        <if test="customerId != null and customerId != ''">
+            AND ls_order.id=#{customerId}
+        </if>
+        <if test="dealerId != null and dealerId != ''">
+            AND ls_order.dealer_id=#{dealerId}
+        </if>
+
+        <if test="payType != null and payType != '' ">
+            AND ls_order.pay_type = #{payType}
+        </if>
+
+        <if test='status != null and status != "" and status!= "5"'>
+            AND ls_order.status = #{status}
+        </if>
+        <if test='status=="5"'>
+            AND ls_order.status in ('5','6','7')
+            AND ls_order.order_type in ('0','1','2','3','7')
+        </if>
+        <if test="startTime!=''and startTime!=null">
+            AND ls_order.create_time &gt;=#{startTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="endTime!=''and endTime!=null">
+            AND ls_order.create_time &lt;=#{endTime,jdbcType=TIMESTAMP}
+        </if>
+        <if test="orderType!=null and orderType !=''">
+            AND ls_order.order_type=#{orderType}
+        </if>
+        <if test='status !="5"'>
+            AND ls_order.order_type in ('0','1','2','7')
+        </if>
+        <choose>
+            <when test="orderType ==1 ||orderType==2">
+                order by ls_order.pay_time desc
+            </when>
+            <otherwise>
+                order by ls_order.create_time desc
+            </otherwise>
+        </choose>
+
     </select>
 
     <!-- 根据条件查询一个 -->

+ 10 - 0
pine-admin/src/test/com/pine/admin/modules/business/service/impl/OrderServiceImplTest.java

@@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.List;
+
 /**
  * com.pine.admin.modules.business.service.impl
  *
@@ -27,4 +29,12 @@ public class OrderServiceImplTest {
     public void queryOrder(){
         Order byId = orderService.getById("3694");
     }
+    @Test
+    public void queryAll(){
+        List<Order> allList = orderService.getAllList(null);
+        allList.stream().forEach(o ->{
+            orderService.FullOrderInfo(o);
+        });
+
+    }
 }