wrj 1 år sedan
förälder
incheckning
59dbb2f43a

+ 8 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/domain/TOrder.java

@@ -57,7 +57,7 @@ public class TOrder implements Serializable {
 
     @TableField("fare")
     @ApiModelProperty("车费")
-    private String fare;
+    private BigDecimal fare;
 
     @TableField("distance")
     @ApiModelProperty("距离")
@@ -87,6 +87,13 @@ public class TOrder implements Serializable {
     @ApiModelProperty("订单金额")
     private BigDecimal dTotalMoney;
 
+    /**
+     * 总价
+     */
+    @TableField("total_price")
+    @ApiModelProperty("总价")
+    private BigDecimal totalPrice;
+
     /**
      * 订单状态	订单状态 待接单 0 已接单 1 已到达 2 服务中 3 待评价(已完成) 4 待付款 -1 已取消 -2 已拒绝 -3 已完成(已评价)5
      */

+ 3 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/TXiangmu.java

@@ -113,6 +113,9 @@ public class TXiangmu implements Serializable {
     @TableLogic
     private Integer isDelete;
 
+    @TableField(exist = false)
+    private BigDecimal sum;
+
     public String getcId() {
         return cId;
     }

+ 17 - 3
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TOrderServiceImpl.java

@@ -20,6 +20,7 @@ import com.ylx.massage.service.*;
 import com.ylx.massage.utils.MassageUtil;
 import com.ylx.massage.utils.OrderNumberGenerator;
 import org.apache.commons.compress.utils.Lists;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -28,7 +29,9 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 
@@ -80,10 +83,14 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
         //计算车费
         if (order.getDistance() != null) {
             BigDecimal bigDecimal = MassageUtil.calculateTaxiFare(order.getDistance());
-            order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP).toString());
-//            throw new ServiceException("距离不能为空");
+            order.setFare(bigDecimal.setScale(MassageConstants.INTEGER_TWO, RoundingMode.HALF_UP));
         }
-
+        //订单价格
+        List<TXiangmu> list = JSONObject.parseArray(order.getcGoods().toJSONString(), TXiangmu.class);
+        BigDecimal sum = list.stream().map(TXiangmu::getSum).reduce(BigDecimal.ZERO, BigDecimal::add);
+        order.setdTotalMoney(sum);
+        //总价
+        order.setTotalPrice(sum.add(Optional.ofNullable(order.getFare()).orElse(BigDecimal.ZERO)));
         //获取用户默认地址
         TAddress address = addressService.getByOpenId(order.getcOpenId());
         if (address == null) {
@@ -116,6 +123,13 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
 //        }
         // 根据orderid查询订单信息
         TOrder orderNew = getById(order.getcId());
+        if (!orderNew.getnStatus().equals(OrderStatusEnum.WAIT_PAY.getCode())) {
+            throw new ServiceException("该订单已经支付或者超时被取消");
+        }
+        TJs js = jsService.getById(orderNew.getcJsId());
+        if (null == js || js.getnStatus().equals(JsStatusEnum.JS_SERVICE.getCode())) {
+            throw new ServiceException("该技师已在服务中请重新下单");
+        }
         // 从对应账户扣款
         TWxUser user = wxUserService.getByOpenId(orderNew.getcOpenId());
         if (null == user) {

+ 5 - 22
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TRechargeServiceImpl.java

@@ -1,46 +1,29 @@
 package com.ylx.massage.service.impl;
 
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
+
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ijpay.core.IJPayHttpResponse;
-import com.ijpay.core.enums.RequestMethodEnum;
-import com.ijpay.core.kit.PayKit;
-import com.ijpay.core.kit.WxPayKit;
-import com.ijpay.core.utils.DateTimeZoneUtil;
-import com.ijpay.wxpay.WxPayApi;
-import com.ijpay.wxpay.enums.WxDomainEnum;
-import com.ijpay.wxpay.enums.v3.BasePayApiEnum;
-import com.ijpay.wxpay.model.v3.Amount;
-import com.ijpay.wxpay.model.v3.Payer;
-import com.ijpay.wxpay.model.v3.UnifiedOrderModel;
-import com.ylx.common.config.WxPayConfig;
-import com.ylx.common.core.domain.R;
+
 import com.ylx.common.exception.ServiceException;
 import com.ylx.common.utils.StringUtils;
 import com.ylx.massage.domain.TConsumptionLog;
 import com.ylx.massage.domain.TRecharge;
 import com.ylx.massage.domain.TWxUser;
+import com.ylx.massage.enums.BillTypeEnum;
 import com.ylx.massage.mapper.TRechargeMapper;
 import com.ylx.massage.service.TConsumptionLogService;
 import com.ylx.massage.service.TRechargeService;
 import com.ylx.massage.service.TWxUserService;
 import com.ylx.massage.utils.OrderNumberGenerator;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.Map;
 
-import static com.ylx.common.constant.HttpStatus.SUCCESS;
+
 
 
 /**
@@ -104,7 +87,7 @@ public class TRechargeServiceImpl extends ServiceImpl<TRechargeMapper, TRecharge
         tConsumptionLog.setAmount(recharge.getdMoney());
         tConsumptionLog.setBillNo(rechargeNo);
         tConsumptionLog.setOpenId(recharge.getcOpenId());
-        tConsumptionLog.setBillType(1);
+        tConsumptionLog.setBillType(BillTypeEnum.RECHARGE.getCode());
         tConsumptionLog.setNote("微信充值");
         consumptionLogService.save(tConsumptionLog);
         log.info("微信充值成功,充值单号:{},充值金额:{},充值OpenId:{}",rechargeNo,recharge.getdMoney(),user.getcOpenid());

+ 1 - 2
nightFragrance-massage/src/main/java/com/ylx/massage/utils/MassageUtil.java

@@ -40,7 +40,6 @@ public class  MassageUtil {
         if(extraKms.compareTo(BigDecimal.ZERO) > 0) {
             totalFare= totalFare.add(extraKms.multiply(ADDITIONAL_FARE_PER_KM));
         }
-
-        return totalFare;
+        return totalFare.multiply(new BigDecimal("2"));
     }
 }

+ 9 - 1
nightFragrance-massage/src/main/resources/mapper/massage/TOrderMapper.xml

@@ -9,6 +9,7 @@
         <result column="c_js_id" property="cJsId"/>
         <result column="tape" property="tape"/>
         <result column="fare" property="fare"/>
+        <result column="total_price" property="totalPrice"/>
         <result column="parent_no" property="parentNo"/>
         <result column="c_open_id" property="cOpenId"/>
         <result column="c_goods" property="cGoods"
@@ -60,6 +61,7 @@
                t_order.c_js_id,
                t_order.tape,
                t_order.fare,
+               t_order.total_price,
                t_order.parent_no,
                t_order.c_open_id,
                t_order.c_goods,
@@ -112,9 +114,15 @@
             <if test="param.orderNo != null and param.orderNo != ''">
                 and t_order.order_no = #{ param.orderNo }
             </if>
-            <if test="param.nStatus != null and param.nStatus != 100">
+            <if test="param.nStatus != null and param.nStatus != 10 and param.nStatus != -10 and param.nStatus != 100">
                 and t_order.n_status = #{ param.nStatus }
             </if>
+            <if test="param.nStatus == 10">
+                and t_order.n_status in(0,1,2,3)
+            </if>
+            <if test="param.nStatus == -10">
+                and t_order.n_status in(-2,-3)
+            </if>
             <if test="param.cJsId != null and param.cJsId != ''">
                 and t_order.c_js_id = #{ param.cJsId }
             </if>