Explorar o código

我的接单接口

tw %!s(int64=4) %!d(string=hai) anos
pai
achega
988c575348

+ 6 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/controller/LiftCaseController.java

@@ -233,4 +233,10 @@ public class LiftCaseController extends BaseController<LiftCaseEntity, LiftCaseQ
     public RestResponse updateCustomerServiceId(@RequestBody LiftCaseEntity liftCaseEntity) {
         return liftCaseService.updateCustomerServiceId(liftCaseEntity);
     }
+
+    @GetMapping("/getMyCase")
+    @ApiOperation(value = "我的接单")
+    public RestResponse getMyCase(Long userId) {
+        return liftCaseService.getMyCase(userId);
+    }
 }

+ 10 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/mapper/LiftCaseMapper.java

@@ -113,4 +113,14 @@ public interface LiftCaseMapper extends BaseMapper<LiftCaseEntity> {
     
     @Select("SELECT * FROM lift_case WHERE (((data_table=1 AND statuz=1) OR (data_table=2 AND statuz=0)) AND (charger_id!=-2) AND accept_status=0) OR (((data_table=1 AND statuz=1) OR (data_table=2 AND statuz=0)) AND is_platform_specified=1 AND accept_status=0)")
     List<LiftCaseEntity>getCaseIsToAccept();
+
+    /**
+     * 查询问诊或者出诊单数(全部状态的)
+     * @return
+     */
+    @Select("select count(id) from lift_case where data_table = #{dataTable} and charger_id = #{userId}")
+    int selectDataTableCount(@Param("dataTable")Integer dataTable,@Param("userId")Long userId);
+
+    @Select("select count(id) from lift_case where data_table = #{dataTable} and charger_id = #{userId} and statuz < #{statuz}")
+    int selectDealingCount(@Param("dataTable")Integer dataTable,@Param("userId")Long userId,@Param("statuz")Integer statuz);
 }

+ 41 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/mapper/entity/MyCaseVo.java

@@ -0,0 +1,41 @@
+package cn.com.ty.lift.ud.chat.mapper.entity;
+
+import cn.com.ty.lift.ud.common.BaseEntity;
+import cn.com.ty.lift.ud.liftCaseAppeal.mapper.entity.LiftCaseAppealEntity;
+import cn.com.ty.lift.ud.question.mapper.entity.QuestionBankEntity;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 我的接单
+ * 
+ * @author Xson
+ * @date 2020-04-23
+ */
+
+@Data
+public class MyCaseVo {
+
+
+    @ApiModelProperty("总收益")
+    private BigDecimal totalMoney;
+
+    @ApiModelProperty("问诊单数")
+    private Integer askNum;
+
+    @ApiModelProperty("出诊单数")
+    private Integer outNum;
+
+    @ApiModelProperty("待处理数量")
+    private Integer dealingNum;
+
+}

+ 2 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/ILiftCaseService.java

@@ -107,4 +107,6 @@ public interface ILiftCaseService extends IService<LiftCaseEntity> {
     RestResponse updateCustomerServiceId(LiftCaseEntity liftCaseEntity);
     
     void updateColorGrade();
+
+    RestResponse getMyCase(Long userId);
 }

+ 41 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/impl/LiftCaseServiceImpl.java

@@ -6,8 +6,10 @@ import java.time.ZoneOffset;
 import java.util.ArrayList;
 import java.util.List;
 
+import cn.com.ty.lift.ud.chat.mapper.entity.MyCaseVo;
 import cn.com.ty.lift.ud.operation.service.ICommissionSettingService;
 import cn.com.ty.lift.ud.operation.service.IOtherSettingService;
+import cn.com.ty.lift.ud.payment.service.IUserBillService;
 import cn.com.ty.lift.ud.question.mapper.entity.QuestionBankEntity;
 import cn.com.ty.lift.ud.question.service.IQuestionBankService;
 import cn.com.ty.lift.ud.redis.RedisUtil;
@@ -107,6 +109,7 @@ public class LiftCaseServiceImpl extends ServiceImpl<LiftCaseMapper, LiftCaseEnt
     @Autowired
     private ICommissionSettingService iCommissionSettingService;
 
+
     /**
      * 问诊: 0用户新建1用户已付款2专家解决问题3用户确认问题已解决4用户已评论5专家已归档; 出诊: 0用户新建1用户付款2专家到场打卡3用户确认打卡4专家解决问题5用户确认问题已解决
      */
@@ -893,4 +896,42 @@ public class LiftCaseServiceImpl extends ServiceImpl<LiftCaseMapper, LiftCaseEnt
             caseMapper.updateColorGarde(liftCase.getId());
         }
     }
+
+    /**
+     * 我的接单
+     * 返回 总收益(根据流水查询)、问诊单数(全部状态的)、出诊单数(全部状态的)、待处理数量(问诊出诊都是 已接单 状态)
+     *  专家收益 =
+     *  收入:打赏 2  出诊问诊收入 4  专家惩罚 9
+     *  支出:专家惩罚 9  申诉退款 10
+     * @param userId
+     * @return
+     */
+    @Override
+    public RestResponse getMyCase(Long userId) {
+        //问诊数量
+        int askNum = caseMapper.selectDataTableCount(1,userId);
+        //出诊数量
+        int outNum = caseMapper.selectDataTableCount(2,userId);
+        //问诊待处理数量就是,待评价之前所有状态的,不包括申诉的  即状态值 小于4的
+        int askDealingNum = caseMapper.selectDealingCount(1,userId,4);
+        //出诊待处理数量就是,待评价之前所有状态的,不包括申诉的  即状态值 小于5的
+        int outDealingNum = caseMapper.selectDealingCount(2,userId,5);
+        //总的待处理数量
+        int totalDealingNum = askDealingNum + outDealingNum;
+        //根据流水查询总收益
+        //专家收入:打赏 2  出诊问诊收入 4  专家惩罚 9 (撤销惩罚)    之和
+        //专家支出:专家惩罚 9   申诉退款 10  之和
+        BigDecimal income = userBillMapper.selectIncome(userId);
+        BigDecimal outcome = userBillMapper.selectOutcome(userId);
+        income = income == null?new BigDecimal(0):income;
+        outcome = outcome == null?new BigDecimal(0):outcome;
+        BigDecimal total = income.subtract(outcome);
+        //汇总
+        MyCaseVo vo = new MyCaseVo();
+        vo.setTotalMoney(total);
+        vo.setAskNum(askNum);
+        vo.setOutNum(outNum);
+        vo.setDealingNum(totalDealingNum);
+        return RestResponse.success(vo,"查询成功");
+    }
 }

+ 16 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/payment/mapper/UserBillMapper.java

@@ -50,4 +50,20 @@ public interface UserBillMapper extends BaseMapper<UserBillEntity> {
      */
     @Select("select * from user_bill WHERE flow_num = #{orders} ")
     UserBillEntity getByFlowNum(@Param("orders") String orders);
+
+    /**
+     * 专家收入:打赏 2  出诊问诊收入 4  专家惩罚 9 (撤销惩罚)    之和
+     * @param userId
+     * @return
+     */
+    @Select("select sum(amount) as income from user_bill where user_id  = #{userId}  and type = 2 and business_type in (2,4,9)")
+    BigDecimal selectIncome(@Param("userId")Long userId);
+
+    /**
+     * 专家支出:专家惩罚 9   申诉退款 10  之和
+     * @param userId
+     * @return
+     */
+    @Select("select sum(amount) as income from user_bill where user_id  = #{userId}  and type = 1 and business_type in (9,10);")
+    BigDecimal selectOutcome(@Param("userId")Long userId);
 }