chenjiahe
2024-03-01 f87850bb6c6109a3bda06ab474575631407bbf09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.hx.phip.tool.order;
 
import com.hx.common.service.CommonService;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.common.OrderTotalConstants;
import com.hx.phiappt.model.consume.ConsumePayItem;
import com.hx.phiappt.model.order.OrdersTotal;
import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed;
import com.hx.phip.dao.mapper.ConsumePayItemMapper;
import com.hx.phip.dao.mapper.UserMoneyUnclaimedMapper;
import com.hx.util.StringUtils;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**订单工具类
 * @author CJH*/
public class OrderTool {
 
    /**获取一级子单的支付方式
     * @param orderOneId 子单标识
     * @param commonService 医生
     * @return 支付方式集合
     */
    public static List<ConsumePayItem> getOrderOnePay(String orderOneId, CommonService commonService){
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
 
        values.put("typeId",orderOneId);
        sqlSentence.sqlSentence("SELECT * FROM consume_pay_item WHERE isDel = 0 AND typeId = #{m.typeId}",values);
        return commonService.selectList(ConsumePayItemMapper.class,sqlSentence);
    }
 
    /**获取活动赠送资金奖励记录*/
    public static UserMoneyUnclaimed getActivityGive(OrdersTotal ordersTotal, CommonService commonService){
        //查找领取记录释放存在
        //领取记录是否已领取
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
 
        values.put("orderId",ordersTotal.getId());
        values.put("commonId",ordersTotal.getActivityPageCode());
        sqlSentence.sqlSentence("SELECT * FROM user_money_unclaimed WHERE isDel = 0 AND orderId = #{m.orderId} AND commonId = #{m.commonId}",values);
        return commonService.selectOne(UserMoneyUnclaimedMapper.class,sqlSentence);
    }
 
    /**获取用户活动赠送资金奖励记录-有效*/
    public static List<UserMoneyUnclaimed> getActivityGive(String userId,String commonId,Integer isValid, CommonService commonService){
        //查找领取记录释放存在
        //领取记录是否已领取
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        StringBuilder sql = new StringBuilder();
 
        sql.append("SELECT * FROM user_money_unclaimed WHERE isDel = 0");
        if(isValid != null){
            values.put("isValid",isValid);
            sql.append(" AND isValid = #{m.isValid}");
        }
        if(StringUtils.noNull(userId)){
            values.put("userId",userId);
            sql.append(" AND userId = #{m.userId}");
        }
        if(StringUtils.noNull(commonId)){
            values.put("commonId",commonId);
            sql.append(" AND commonId = #{m.commonId}");
        }
        sqlSentence.sqlSentence(sql.toString(),values);
        return commonService.selectList(UserMoneyUnclaimedMapper.class,sqlSentence);
    }
 
    /**获取用户活动赠送资金奖励记录-获取一条*/
    public static UserMoneyUnclaimed getActivityGiveByOrder(OrdersTotal ordersTotal,Integer isValid, CommonService commonService){
        //根据当前用户,获取到所有的记录
        //领取记录是否已领取
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        StringBuilder sql = new StringBuilder();
 
        values.put("commonId",ordersTotal.getActivityPageCode());
        values.put("userId",ordersTotal.getUserId());
        values.put("payStatus", OrderTotalConstants.PAY_STATUS_SUC);
        values.put("activityPageType", ordersTotal.getActivityPageType());
        values.put("activityPageCode", ordersTotal.getActivityPageCode());
        sql.append("SELECT umu.* FROM orders_total ot ");
        sql.append(" JOIN user_money_unclaimed umu ON umu.orderId = ot.id AND umu.isDel = 0 AND umu.commonId = #{m.commonId}");
        if(isValid != null){
            values.put("isValid",isValid);
            sql.append(" AND umu.isValid = #{m.isValid}");
        }
        sql.append(" WHERE ot.isDel = 0 AND ot.activityPageType = #{m.activityPageType} AND ot.activityPageCode = #{m.activityPageCode}" +
                " AND ot.userId = #{m.userId} AND ot.payStatus = #{m.payStatus} ORDER BY umu.createTime ASC LIMIT 1");
 
        sqlSentence.sqlSentence(sql.toString(),values);
        return commonService.selectOne(UserMoneyUnclaimedMapper.class,sqlSentence);
    }
 
 
}