fei.wang
2024-03-07 80c20bb65f4b73d8beb817e0d595889cd44479dd
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package com.flow.controller;
 
import com.flow.pojo.Card;
import com.flow.pojo.Chongzhi;
import com.flow.pojo.TbFuwuqi;
import com.flow.service.CardService;
import com.flow.service.ChongZhiService;
import com.flow.service.TbFuwuqiService;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping({"/order"})
public class orderController {
    private String SecretId = "AKIDrjZOI4e6KLZu9FAsSRN8eOwSt52lbMBz";
    private String SecretKey = "xnRtHUL3YqdMyOLVSBjKkz1pQoxujS4d";
    @Autowired
    CardService cardService;
    @Autowired
    ChongZhiService chongZhiService;
 
    @Autowired
    TbFuwuqiService tbFuwuqiService;
 
    public orderController() {
    }
 
    @PostMapping({"payed"})
    public void changeOrder(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String out_trade_no = request.getParameter("out_trade_no");
        double money = Double.parseDouble(request.getParameter("total_amount"));
        String formattedTime = currentTime.format(formatter);
        String card = request.getParameter("body");
        String[] values = card.split(",");
        double mones = (double)values.length * money;
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        String formattedMones = decimalFormat.format(mones);
        double result = Double.parseDouble(formattedMones) * 0.06;
        String formattedResult = decimalFormat.format(result);
        double finalResult = Double.parseDouble(formattedMones) - Double.parseDouble(formattedResult);
        String kaiMoney = decimalFormat.format(finalResult);
        String[] var21 = values;
        int var22 = values.length;
 
        for(int var23 = 0; var23 < var22; ++var23) {
            String value = var21[var23];
            Card card1 = new Card();
            card1.setRechargedate(formattedTime);
            card1.setRechargemoney(String.valueOf(money));
            card1.setCardnumber(value);
            this.cardService.UpdateCardNum(card1);
        }
 
        System.out.println("充值记录");
        String value1 = request.getParameter("subject");
        System.out.println(value1);
        Chongzhi chongzhi;
        if (value1 != null && value1 != "") {
            chongzhi = new Chongzhi();
            chongzhi.setCzcard(card);
            chongzhi.setCzmoney(formattedMones);
            chongzhi.setJynum(out_trade_no);
            chongzhi.setCzdate(formattedTime);
            chongzhi.setStatus("未开票");
            chongzhi.setKaimoney(kaiMoney);
            chongzhi.setCompany(value1);
            this.chongZhiService.addChongZhi(chongzhi);
        } else {
            chongzhi = new Chongzhi();
            chongzhi.setCzcard(card);
            chongzhi.setCzmoney(formattedMones);
            chongzhi.setJynum(out_trade_no);
            chongzhi.setCzdate(formattedTime);
            chongzhi.setCompany("无");
            chongzhi.setStatus("未开票");
            chongzhi.setKaimoney(kaiMoney);
            this.chongZhiService.addChongZhi(chongzhi);
        }
 
        System.out.println("添加成功");
 
        try {
            Credential cred = new Credential(this.SecretId, this.SecretKey);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String[] phoneNumberSet1 = new String[]{"15210640466"};
            req.setPhoneNumberSet(phoneNumberSet1);
            req.setSmsSdkAppId("1400838975");
            req.setSignName("北京华星北斗智控");
            req.setTemplateId("1907853");
            String[] templateParamSet1 = new String[]{value1, formattedTime, String.valueOf(formattedMones), String.valueOf(values.length)};
            req.setTemplateParamSet(templateParamSet1);
            SendSmsResponse resp = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(resp));
        } catch (TencentCloudSDKException var30) {
            System.out.println(var30.toString());
            response.getWriter().println("success");
        }
 
        response.getWriter().println("success");
    }
 
    @PostMapping({"payedFuwuqi"})
    public void changeOrderFuwuqi(HttpServletRequest request, HttpServletResponse response) throws ParseException, IOException {
        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String out_trade_no = request.getParameter("out_trade_no");
        double money = Double.parseDouble(request.getParameter("total_amount"));
//        double money = 0.02;
        String formattedTime = currentTime.format(formatter);
        String card = request.getParameter("body");
//        String card = "北京华星北斗智控技术有限公司";
        String[] values = card.split(",");
        double mones = (double)values.length * money;
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        String formattedMones = decimalFormat.format(mones);
        double result = Double.parseDouble(formattedMones) * 0.06;
        String formattedResult = decimalFormat.format(result);
        double finalResult = Double.parseDouble(formattedMones) - Double.parseDouble(formattedResult);
        String kaiMoney = decimalFormat.format(finalResult);
        String[] var21 = values;
        int var22 = values.length;
 
        for(int var23 = 0; var23 < var22; ++var23) {
            String value = var21[var23];
            System.out.println(value);
            TbFuwuqi tbFuwuqi = new TbFuwuqi();
            tbFuwuqi.setRechargedate(formattedTime);
            tbFuwuqi.setRechargemoney(String.valueOf(money));
 
            tbFuwuqi.setCompany("北京华星北斗智控技术有限公司");
            tbFuwuqi.setCompany(value);
            this.tbFuwuqiService.Updatefuwuqi(tbFuwuqi);
        }
 
        System.out.println("充值记录");
        String value1 = request.getParameter("subject");
        System.out.println(value1);
        Chongzhi chongzhi;
        if (value1 != null && value1 != "") {
            chongzhi = new Chongzhi();
            chongzhi.setCzcard(card);
            chongzhi.setCzmoney(formattedMones);
            chongzhi.setJynum(out_trade_no);
            chongzhi.setCzdate(formattedTime);
            chongzhi.setStatus("未开票");
            chongzhi.setKaimoney(kaiMoney);
            chongzhi.setCompany(value1);
            this.chongZhiService.addChongZhi(chongzhi);
        } else {
            chongzhi = new Chongzhi();
            chongzhi.setCzcard(card);
            chongzhi.setCzmoney(formattedMones);
            chongzhi.setJynum(out_trade_no);
            chongzhi.setCzdate(formattedTime);
            chongzhi.setCompany("无");
            chongzhi.setStatus("未开票");
            chongzhi.setKaimoney(kaiMoney);
            this.chongZhiService.addChongZhi(chongzhi);
        }
 
        System.out.println("添加成功");
 
        try {
            Credential cred = new Credential(this.SecretId, this.SecretKey);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            SmsClient client = new SmsClient(cred, "ap-beijing", clientProfile);
            SendSmsRequest req = new SendSmsRequest();
            String[] phoneNumberSet1 = new String[]{"15210640466"};
            req.setPhoneNumberSet(phoneNumberSet1);
            req.setSmsSdkAppId("1400838975");
            req.setSignName("北京华星北斗智控");
            req.setTemplateId("1907853");
            String[] templateParamSet1 = new String[]{value1, formattedTime, String.valueOf(formattedMones), String.valueOf(values.length)};
            req.setTemplateParamSet(templateParamSet1);
            SendSmsResponse resp = client.SendSms(req);
            System.out.println(SendSmsResponse.toJsonString(resp));
        } catch (TencentCloudSDKException var30) {
            System.out.println(var30.toString());
            response.getWriter().println("success");
        }
 
        response.getWriter().println("success");
    }
}