// // 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"); } }