瀏覽代碼

中台达人尾款代码

ldz 1 月之前
父節點
當前提交
8d0999564f

+ 13 - 1
alien-entity/src/main/java/shop/alien/entity/store/LifeUserExpertOrder.java

@@ -115,7 +115,7 @@ public class LifeUserExpertOrder extends Model<LifeUserExpertOrder> {
     @TableField(value = "advance_payment_status")
     private String advancePaymentStatus;
 
-    @ApiModelProperty(value = "申请尾款按钮")
+    @ApiModelProperty(value = "申请尾款按钮状态 0未点击  1已点击审核中  2已点击审核通过  3已点击审核拒绝")
     @TableField(value = "end_funds_button")
     private String endFundsButton;
 
@@ -127,4 +127,16 @@ public class LifeUserExpertOrder extends Model<LifeUserExpertOrder> {
     @TableField(value = "advance_payment_time")
     private Date advancePaymentTime;
 
+    @ApiModelProperty(value = "点击申请尾款按钮时间")
+    @TableField(value = "end_funds_time")
+    private Date endFundsTime;
+
+    @ApiModelProperty(value = "尾款审核时间")
+    @TableField(value = "end_payment_time")
+    private Date endPaymentTime;
+
+    @ApiModelProperty(value = "尾款拒绝原因")
+    @TableField(value = "end_payment_refusal")
+    private String endPaymentRefusal;
+
 }

+ 14 - 2
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeUserExpertOrderVo.java

@@ -86,10 +86,10 @@ public class LifeUserExpertOrderVo extends LifeUserExpertOrder {
     private String userPhone;
 
     @ApiModelProperty(value = "佣金")
-    private String commission;
+    private BigDecimal commission;
 
     @ApiModelProperty(value = "预付款")
-    private String advance;
+    private BigDecimal advance;
 
     @ApiModelProperty(value = "预付款比例")
     @TableField(value = "advance_rate")
@@ -112,4 +112,16 @@ public class LifeUserExpertOrderVo extends LifeUserExpertOrder {
 
     @ApiModelProperty(value = "门店电话")
     private String storeTel;
+
+    @ApiModelProperty(value = "订单GMV  订单表gmv数据保存两位小数")
+    private String orderNewGmv;
+
+    @ApiModelProperty(value = "达人昵称")
+    private String userName;
+
+    @ApiModelProperty(value = "尾款比例")
+    private Integer endPaymentRate;
+
+    @ApiModelProperty(value = "尾款金额")
+    private BigDecimal endPayment;
 }

+ 6 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/LifeUserExpertVo.java

@@ -123,5 +123,11 @@ public class LifeUserExpertVo extends LifeUserExpert {
     @ApiModelProperty(value = "预付款比例 ")
     private Integer advanceRate;
 
+    @ApiModelProperty(value = "完成时间 ")
+    private Date completeTime;
+
+    @ApiModelProperty(value = "店铺名称")
+    private String storeName;
+
 
 }

+ 15 - 3
alien-entity/src/main/java/shop/alien/mapper/LifeUserExpertOrderMapper.java

@@ -11,6 +11,7 @@ import shop.alien.entity.store.LifeUserExpertOrder;
 import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
 import shop.alien.entity.store.vo.LifeUserExpertVo;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -97,14 +98,14 @@ public interface LifeUserExpertOrderMapper extends BaseMapper<LifeUserExpertOrde
 
     @Update("UPDATE " +
             "life_user_expert_order " +
-            "SET first_funds_button = #{firstButton}, " +
+            "SET end_funds_time = #{date}, " +
             "end_funds_button = #{endButton} " +
             "WHERE order_no = #{orderNo}")
-    void updateButton(@Param("firstButton") String firstButton,@Param("endButton") String endButton,@Param("orderNo") String orderNo);
+    void updateButton(@Param("firstButton") Date date, @Param("endButton") String endButton, @Param("orderNo") String orderNo);
 
 
 
-    @Select("SELECT ccc.* ,info.store_name,info.store_tel,user.real_name,expert.promote_type,expert.advance_rate,expert.commission_rate,user.user_phone,user.id_card,package.name " +
+    @Select("SELECT ccc.* ,info.store_name,info.store_tel,user.real_name,user.user_name,expert.promote_type,expert.advance_rate,expert.commission_rate,user.user_phone,user.id_card,package.name " +
             "FROM life_user_expert_order ccc " +
             "LEFT JOIN store_info info on info.id = ccc.store_id " +
             "left join life_user_expert expert on expert.id = ccc.expert_id " +
@@ -113,4 +114,15 @@ public interface LifeUserExpertOrderMapper extends BaseMapper<LifeUserExpertOrde
             " ${ew.customSqlSegment}")
 
     List<LifeUserExpertOrderVo> getAdvancePaymentList(@Param(Constants.WRAPPER) QueryWrapper<LifeUserExpertVo> wrapper);
+
+
+
+    @Select("SELECT ccc.* ,info.store_name,info.store_tel,user.real_name,user.user_name,expert.promote_type,expert.advance_rate,expert.commission_rate,user.user_phone,user.id_card,package.name " +
+            "FROM life_user_expert_order ccc " +
+            "LEFT JOIN store_info info on info.id = ccc.store_id " +
+            "left join life_user_expert expert on expert.id = ccc.expert_id " +
+            "left join life_user user on user.id = expert.user_id " +
+            "left join life_promotion_package package on package.id = ccc.package_id " +
+            " ${ew.customSqlSegment}")
+    List<LifeUserExpertOrderVo> getFinalPaymentList(@Param(Constants.WRAPPER) QueryWrapper<LifeUserExpertVo> wrapper);
 }

+ 4 - 1
alien-entity/src/main/resources/mapper/LifeUserExpertOrderMapper.xml

@@ -29,12 +29,15 @@
         <result column="end_funds_button" property="endFundsButton" />
         <result column="reason_refusal" property="reasonRefusal" />
         <result column="advance_payment_time" property="advancePaymentTime" />
+        <result column="end_funds_time" property="endFundsTime" />
+        <result column="end_payment_time" property="endPaymentTime" />
+        <result column="end_payment_refusal" property="endPaymentRefusal" />
 
     </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, order_id, expert_id, package_id , store_id, order_money, account_money, order_time, complete_time, first_payment_time, final_payment_time, order_play_count, order_gmv, actual_gmv, status, delete_flag, created_time, created_user_id, updated_time, updated_user_id, advance_payment_status, end_funds_button ,reason_refusal,advancePaymentTime
+        id, order_id, expert_id, package_id , store_id, order_money, account_money, order_time, complete_time, first_payment_time, final_payment_time, order_play_count, order_gmv, actual_gmv, status, delete_flag, created_time, created_user_id, updated_time, updated_user_id, advance_payment_status, end_funds_button ,reason_refusal,advancePaymentTime,endFundsTime,endPaymentTime,endPaymentRefusal
     </sql>
 
 </mapper>

+ 43 - 1
alien-store/src/main/java/shop/alien/store/controller/LifeUserExpertController.java

@@ -17,6 +17,7 @@ import shop.alien.store.service.LifeUserExpertService;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 @Api(tags = {"平台-达人管理"})
 @Slf4j
@@ -166,7 +167,7 @@ public class LifeUserExpertController {
                         @ApiImplicitParam(name = "name", value = "套餐名称", dataType = "String", paramType = "query"),
                         @ApiImplicitParam(name = "storeTel", value = "门店电话", dataType = "String", paramType = "query"),
                         @ApiImplicitParam(name = "orderNo", value = "订单号", dataType = "String", paramType = "query"),
-                        @ApiImplicitParam(name = "orderMoney", value = "用户id", dataType = "String", paramType = "query"),
+                        @ApiImplicitParam(name = "orderMoney", value = "订单金额", dataType = "String", paramType = "query"),
                         @ApiImplicitParam(name = "advancePaymentStatus", value = "预付款审核状态", dataType = "String", paramType = "query")
     })
     @GetMapping("/getAdvancePaymentReview")
@@ -175,5 +176,46 @@ public class LifeUserExpertController {
         return R.data(lifeUserExpertService.getAdvancePaymentReview(id, reasonRefusal, userPhone, name,storeTel,orderNo,orderMoney,advancePaymentStatus));
     }
 
+    @ApiOperation("达人尾款列表")
+    @ApiOperationSupport(order = 13)
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "分页页数", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "size", value = "分页条数", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "realName", value = "真实姓名", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "userPhone", value = "联系电话", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "endFundsButton", value = "申请尾款按钮状态(审核状态)", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderCreatedTime", value = "下单开始时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderEndTime", value = "下单结束时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderCreatedTime", value = "支付开始时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderEndTime", value = "支付结束时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "firstCompleteTime", value = "开始完成时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "endCompleteTime", value = "结束完成时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "createdEndPaymentTime", value = "开始申请时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "endEndPaymentTime", value = "结束申请时间", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "name", value = "套餐名称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderNo", value = "订单编号", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "storeName", value = "商家昵称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query")
+    })
+    @GetMapping("/getFinalPaymentList")
+    public R<IPage<LifeUserExpertOrderVo>> getFinalPaymentList( Integer page, Integer size,String realName, String userPhone, String advancePaymentStatus, String orderCreatedTime, String orderEndTime ,String firstCompleteTime,String endCompleteTime,String createdEndPaymentTime,String endEndPaymentTime,String name, Integer userId) {
+        log.info("LifeUserExpertController.getViewDetails?userId={}",userId);
+        return R.data(lifeUserExpertService.getFinalPaymentList(page, size, realName, userPhone, advancePaymentStatus, orderCreatedTime, orderEndTime, firstCompleteTime,endCompleteTime,createdEndPaymentTime,endEndPaymentTime,name, userId));
+    }
 
+    @ApiOperation("达人尾款审核接口")
+    @ApiOperationSupport(order = 14)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "达人订单表id", dataType = "Integer", paramType = "query",required = true),
+            @ApiImplicitParam(name = "endPaymentRefusal", value = "尾款拒绝原因", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "userPhone", value = "用户手机号", dataType = "String", paramType = "query",readOnly = true),
+            @ApiImplicitParam(name = "name", value = "套餐名称", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "storeTel", value = "门店电话", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderNo", value = "订单号", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "orderMoney", value = "用户id", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "endFundsButton", value = "申请尾款状态", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/getFinalPaymentReview")
+    public R <Map<String,String>> getFinalPaymentReview(Integer id, String endPaymentRefusal, String userPhone, String name, String storeTel, String orderNo, String orderMoney, String endFundsButton) {
+        log.info("LifeUserExpertController.getViewDetails?Id={},endPaymentRefusal{},userPhone{},name{},orderNo{},orderMoney{},endFundsButton{}",id,endPaymentRefusal,userPhone,name,orderNo,orderMoney,endFundsButton);
+        return R.data(lifeUserExpertService.getFinalPaymentReview(id, endPaymentRefusal, userPhone, name,storeTel,orderNo,orderMoney,endFundsButton));
+    }
 }

+ 6 - 0
alien-store/src/main/java/shop/alien/store/service/LifeUserExpertService.java

@@ -3,12 +3,14 @@ package shop.alien.store.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import lombok.Data;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeUserExpert;
 import shop.alien.entity.store.vo.ExpertGoodsTypeVo;
 import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
 import shop.alien.entity.store.vo.LifeUserExpertVo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -49,4 +51,8 @@ public interface LifeUserExpertService extends IService<LifeUserExpert> {
     IPage<LifeUserExpertOrderVo> getAdvancePaymentList(Integer page, Integer size,String realName, String userPhone, String advancePaymentStatus, String orderCreatedTime, String orderEndTime ,String name, Integer userId);
 
     Boolean getAdvancePaymentReview(Integer id,String reasonRefusal, String userPhone,String name,String storeTel,String orderNo, String orderMoney,String advancePaymentStatus);
+
+    IPage<LifeUserExpertOrderVo> getFinalPaymentList(Integer page, Integer size,String realName, String userPhone, String advancePaymentStatus, String orderCreatedTime, String orderEndTime ,String firstCompleteTime,String endCompleteTime,String createdEndPaymentTime,String endEndPaymentTime,String name, Integer userId);
+
+    Map<String,String> getFinalPaymentReview(Integer id, String endPaymentRefusal, String userPhone, String name, String storeTel, String orderNo, String orderMoney, String endFundsButton);
 }

+ 5 - 8
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserExpertOrderServiceImpl.java

@@ -18,10 +18,7 @@ import shop.alien.util.common.ListToPage;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * <p>
@@ -173,15 +170,15 @@ public class LifeUserExpertOrderServiceImpl extends ServiceImpl<LifeUserExpertOr
         Map<String, Object> resultMap = new HashMap<>();
         //buttonType 0: 首次打款 1: 尾次打款  buttonStatus  0未点击  1已点击审核中  2已点击审核通过
         if ("0".equals(buttonType)){
-            String firstButton = "1";
+            Date date = new Date();
             String endButton = "";
-            lifeUserExpertOrderMapper.updateButton(firstButton,endButton,orderNo);
+            lifeUserExpertOrderMapper.updateButton(date,endButton,orderNo);
             resultMap.put("firstButton", buttonStatus);
             return resultMap;
         } else if ("1".equals(buttonType)) {
             String endButton = "1";
-            String firstButton = "";
-            lifeUserExpertOrderMapper.updateButton(firstButton,endButton,orderNo);
+            Date date = new Date();
+            lifeUserExpertOrderMapper.updateButton(date,endButton,orderNo);
             resultMap.put("endButton", buttonStatus);
             LifeNotice lifeMessage = new LifeNotice();
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

+ 133 - 21
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserExpertServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.ExpertGoodsTypeVo;
 import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
@@ -95,24 +96,26 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
             lifeUserExpert.setAdvanceRate(advanceRate);
             String text = "您在"+formattedDate+"提交的信息已经通过审核。恭喜您成为达人。";
             String title = "审核通过通知";
-            sendMessage(expertStatus, userPhone, text,title);
+            String phone="user_"+userPhone;
+            sendMessage(expertStatus, phone, text,title);
         } else if (expertStatus == 2) {
             lifeUserExpert.setRefuseBecause(comment);
             lifeUserExpert.setExpertStatus(2);
             String text = "您在"+formattedDate+"提交的信息未通过审核,拒绝原因:"+comment+"。请您重新填写信息后再次提交至平台审核。";
             String title = "审核失败通知";
-            sendMessage(expertStatus, userPhone, text,title);
+            String phone="user_"+userPhone;
+            sendMessage(expertStatus, phone, text,title);
         }
         return lifeUserExpertMapper.updateExpert(lifeUserExpert);
     }
 
 
-    public void sendMessage(Integer expertStatus,String userPhone ,String text,String title) {
+    public void sendMessage(Integer expertStatus,String phone ,String text,String title) {
         LifeNotice lifeMessage = new LifeNotice();
         if (expertStatus == 0){
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("message", text);
-            lifeMessage.setReceiverId("user_"+userPhone);
+            lifeMessage.setReceiverId(phone);
             lifeMessage.setContext(jsonObject.toJSONString());
             lifeMessage.setNoticeType(1);
             lifeMessage.setIsRead(0);
@@ -123,7 +126,7 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
         } else if (expertStatus == 2) {
             JSONObject jsonObject = new JSONObject();
             jsonObject.put("message", text);
-            lifeMessage.setReceiverId("user_"+userPhone);
+            lifeMessage.setReceiverId(phone);
             lifeMessage.setContext(jsonObject.toJSONString());
             lifeMessage.setNoticeType(1);
             lifeMessage.setIsRead(0);
@@ -131,6 +134,18 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
             lifeMessage.setTitle(title);
             lifeMessage.setSenderId("system");
             lifeNoticeMapper.insert(lifeMessage);
+        } else if (expertStatus == 2) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("message", text);
+            lifeMessage.setReceiverId(phone);
+            lifeMessage.setContext(jsonObject.toJSONString());
+            lifeMessage.setNoticeType(1);
+            lifeMessage.setIsRead(0);
+            lifeMessage.setDeleteFlag(0);
+            lifeMessage.setTitle(title);
+            lifeMessage.setSenderId("system");
+            lifeNoticeMapper.insert(lifeMessage);
+
         }
     }
 
@@ -422,49 +437,146 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
         for (LifeUserExpertOrderVo lifeUserExpertOrderVo : list) {
             int advanceRate = lifeUserExpertOrderVo.getAdvanceRate();
             int commissionRate = lifeUserExpertOrderVo.getCommissionRate();
-            BigDecimal advanceAmount = lifeUserExpertOrderVo.getOrderMoney().multiply(BigDecimal.valueOf(advanceRate))
-                    .divide(new BigDecimal(100));
+            lifeUserExpertOrderVo.setOrderNewGmv(String.valueOf(lifeUserExpertOrderVo.getOrderGmv().setScale(2, BigDecimal.ROUND_HALF_UP)));
             BigDecimal commissionAmount = lifeUserExpertOrderVo.getOrderMoney().multiply(BigDecimal.valueOf(commissionRate))
                     .divide(new BigDecimal(100));
-            lifeUserExpertOrderVo.setAdvance(advanceAmount.toString());
-            lifeUserExpertOrderVo.setCommission(commissionAmount.toString());
+            BigDecimal difference = lifeUserExpertOrderVo.getOrderMoney().subtract(commissionAmount);
+            BigDecimal advanceAmount = difference.multiply(BigDecimal.valueOf(advanceRate))
+                    .divide(new BigDecimal(100));
+            lifeUserExpertOrderVo.setAdvance(advanceAmount);
+            lifeUserExpertOrderVo.setCommission(commissionAmount);
         }
         return ListToPage.setPage(list,page, size);
     }
 
     @Override
     public Boolean getAdvancePaymentReview(Integer id,String reasonRefusal,String userPhone, String name,String storeTel,String orderNo, String orderMoney,String advancePaymentStatus) {
-        LifeUserExpertOrder lifeUserExpertOrder =new LifeUserExpertOrder() ;
-        lifeUserExpertOrder.setId(id);
-        lifeUserExpertOrder.setAdvancePaymentStatus(advancePaymentStatus);
-        lifeUserExpertOrder.setAdvancePaymentTime(new Date());
-        lifeUserExpertOrder.setReasonRefusal(reasonRefusal);
-        int i=lifeUserExpertOrderMapper.updateById(lifeUserExpertOrder);
+
 
         Integer advancePaymentStatu= Integer.valueOf(advancePaymentStatus);
+        LifeUserExpertOrder lifeUserExpertOrder =new LifeUserExpertOrder() ;
         if ("0".equals(advancePaymentStatus)){
+            //审核通过,修改订单表审核状态,添加首次打款时间
+            lifeUserExpertOrder.setId(id);
+            lifeUserExpertOrder.setAdvancePaymentStatus(advancePaymentStatus);
+            lifeUserExpertOrder.setAdvancePaymentTime(new Date());
+            lifeUserExpertOrder.setReasonRefusal(reasonRefusal);
+            lifeUserExpertOrder.setFirstPaymentTime(new Date());
+            int i=lifeUserExpertOrderMapper.updateById(lifeUserExpertOrder);
             String text = "您的"+name+"已被商家订购,可在应用内我的-我的钱包中查看预付款金额。";
             String title = "发放预付款通知";
-            sendMessage(advancePaymentStatu,userPhone ,text,title);
+            String  phone = "user_"+userPhone;
+            sendMessage(advancePaymentStatu,phone ,text,title);
         } else if ("2".equals(advancePaymentStatus)){
             String text = "您订购的达人推广套餐-"+name+",审核未通过,拒绝原因:"+reasonRefusal+",平台会在1-3个工作日将全部款项发放到你的支付宝账户,请注意查收。如未到账,请联系客服处理。";
             String title = "订单退款通知";
-            sendMessage(advancePaymentStatu,storeTel ,text,title);
-
+            String  phone = "store_"+storeTel;
+            sendMessage(advancePaymentStatu,phone ,text,title);
 
             //退款逻辑
             String partialRefundCode = "";
             String result=aliApi.processRefund(orderNo, orderMoney, reasonRefusal, partialRefundCode);
+            //支付宝退款成功,发送系统消息,更新订单表审核状态
             if ("调用成功".equals(result)){
+                lifeUserExpertOrder.setId(id);
+                lifeUserExpertOrder.setAdvancePaymentStatus(advancePaymentStatus);
+                lifeUserExpertOrder.setAdvancePaymentTime(new Date());
+                lifeUserExpertOrder.setReasonRefusal(reasonRefusal);
+                int i=lifeUserExpertOrderMapper.updateById(lifeUserExpertOrder);
                 String text1 = "您订购的达人推广套餐-"+name+",订单金额:"+orderMoney+"元,已经成功发放到您的支付宝账户,请注意查收。";
                 String title1 = "退款到账成功通知";
                 sendMessage(advancePaymentStatu,userPhone ,text1,title1);
             }
         }
-        if (i>0){
-            return true;
-        }
+
         return false;
     }
 
+    @Override
+    public IPage<LifeUserExpertOrderVo> getFinalPaymentList(Integer page, Integer size,String realName, String userPhone, String advancePaymentStatus, String orderCreatedTime, String orderEndTime ,String firstCompleteTime,String endCompleteTime,String createdEndPaymentTime,String endEndPaymentTime,String name, Integer userId) {
+        QueryWrapper<LifeUserExpertVo> wrapper = new QueryWrapper<>();
+        wrapper.eq("ccc.delete_flag", 0);
+        wrapper.eq("user.delete_flag", 0);
+        wrapper.eq("info.delete_flag",0);
+        wrapper.eq("expert.delete_flag",0);
+        wrapper.eq("package.delete_flag",0);
+        wrapper.like(StringUtils.isNotEmpty(realName), "user.real_name", realName);
+        wrapper.like(StringUtils.isNotEmpty(userPhone), "user.user_phone", userPhone);
+        if (advancePaymentStatus != null && !advancePaymentStatus.isEmpty()){
+            wrapper.eq("ccc.advance_payment_status", advancePaymentStatus);
+        }
+        if (orderCreatedTime != null && !orderCreatedTime.isEmpty()){
+            wrapper.gt("ccc.order_time", orderCreatedTime);
+        }
+        if (orderEndTime != null && !orderEndTime.isEmpty()) {
+            wrapper.lt("ccc.order_time", orderEndTime);
+        }
+        if (firstCompleteTime != null && !firstCompleteTime.isEmpty()){
+            wrapper.gt("ccc.complete_time", firstCompleteTime);
+        }
+        if (endCompleteTime != null && !endCompleteTime.isEmpty()){
+            wrapper.lt("ccc.complete_time", endCompleteTime);
+        }
+        if (createdEndPaymentTime != null && !createdEndPaymentTime.isEmpty()){
+            wrapper.gt("ccc.end_payment_time", createdEndPaymentTime);
+        }
+        if (endEndPaymentTime != null && !endEndPaymentTime.isEmpty()){
+            wrapper.lt("ccc.end_payment_time", endEndPaymentTime);
+        }
+        List<LifeUserExpertOrderVo> list=lifeUserExpertOrderMapper.getFinalPaymentList(wrapper);
+        for (LifeUserExpertOrderVo lifeUserExpertOrderVo : list) {
+            int advanceRate = lifeUserExpertOrderVo.getAdvanceRate();
+            int commissionRate = lifeUserExpertOrderVo.getCommissionRate();
+            //订单金额
+            lifeUserExpertOrderVo.setOrderNewGmv(String.valueOf(lifeUserExpertOrderVo.getOrderGmv().setScale(2, BigDecimal.ROUND_HALF_UP)));
+            //佣金
+            BigDecimal commissionAmount = lifeUserExpertOrderVo.getOrderMoney().multiply(BigDecimal.valueOf(commissionRate))
+                    .divide(new BigDecimal(100));
+            //预付款
+            BigDecimal difference = lifeUserExpertOrderVo.getOrderMoney().subtract(commissionAmount);
+            BigDecimal advanceAmount = difference.multiply(BigDecimal.valueOf(advanceRate))
+                    .divide(new BigDecimal(100));
+            //尾款
+            BigDecimal endPayment = lifeUserExpertOrderVo.getOrderMoney().subtract(commissionAmount).subtract(advanceAmount);
+
+            lifeUserExpertOrderVo.setAdvance(advanceAmount);
+            lifeUserExpertOrderVo.setCommission(commissionAmount);
+            lifeUserExpertOrderVo.setEndPayment(endPayment);
+            lifeUserExpertOrderVo.setEndPaymentRate(100-advanceRate);
+        }
+        return ListToPage.setPage(list,page, size);
+    }
+
+    @Override
+    public Map<String,String> getFinalPaymentReview(Integer id, String endPaymentRefusal, String userPhone, String name, String storeTel, String orderNo, String orderMoney, String endFundsButton) {
+        Map<String,String> map = new HashMap<>();
+        LifeUserExpertOrder lifeUserExpertOrder =new LifeUserExpertOrder() ;
+        lifeUserExpertOrder.setId(id);
+        lifeUserExpertOrder.setEndFundsButton(endFundsButton);
+        lifeUserExpertOrder.setEndPaymentTime(new Date());
+
+        //endFundsButton  0未点击  1已点击审核中  2已点击审核通过  3已点击审核拒绝
+        Integer endFundsButtons = Integer.valueOf(endFundsButton);
+        if ("2".equals(endFundsButton)){
+            lifeUserExpertOrder.setFinalPaymentTime(new Date());
+            int i=lifeUserExpertOrderMapper.updateById(lifeUserExpertOrder);
+            String text = "您在"+new Date()+"提交的申请尾款信息,已通过审核。尾款可在应用内我的-我的钱包中查看。";
+            String title = "尾款审核通过通知";
+            String  phone = "user_"+userPhone;
+            sendMessage(endFundsButtons,phone ,text,title);
+            map.put("status","审核成功,发送系统消息成功");
+            return map;
+        } else if ("3".equals(endFundsButton)){
+            lifeUserExpertOrder.setEndPaymentRefusal(endPaymentRefusal);
+            int i=lifeUserExpertOrderMapper.updateById(lifeUserExpertOrder);
+            String text = "您在"+new Date()+"提交的申请尾款信息,未通过审核。拒绝原因:"+endPaymentRefusal+"。";
+            String title = "尾款审核失败通知";
+            String  phone = "user_"+userPhone;
+            sendMessage(endFundsButtons,phone ,text,title);
+            map.put("status","审核驳回,发送系统消息成功");
+            return map;
+        }
+        return map;
+    }
+
 }

+ 10 - 0
alien-store/src/main/java/shop/alien/store/util/ali/AliApi.java

@@ -190,6 +190,16 @@ public class AliApi {
             String refundReslut = "";
             if (response.isSuccess()) {
                 refundReslut = "调用成功";
+                // 保存退款信息进入到支付宝记录表
+                JSONObject jsonObject = JSONObject.parseObject(response.getBody()).getJSONObject("alipay_fund_trans_uni_transfer_response");
+                StoreAliPayLog storeAliPayLog = new StoreAliPayLog();
+                storeAliPayLog.setTransAmount(refundAmount);
+                storeAliPayLog.setOutBizNo(jsonObject.getString("out_biz_no"));
+                storeAliPayLog.setOrderId(jsonObject.getString("order_id"));
+                storeAliPayLog.setPayFundOrderId(jsonObject.getString("pay_fund_order_id"));
+                storeAliPayLog.setTransDate(jsonObject.getString("trans_date"));
+                storeAliPayLogService.save(storeAliPayLog);
+
             } else {
                 log.warn("AliPayConfig.processRefund ERROR Msg={}", response.getBody());
                 refundReslut = "调用失败";