| | |
| | | import com.stylefeng.guns.core.common.constant.factory.PageFactory; |
| | | import com.stylefeng.guns.core.shiro.ShiroKit; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.modular.system.model.TOrderCharter; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.model.TIntegralOrder; |
| | | import com.stylefeng.guns.modular.system.service.ITIntegralOrderService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ITIntegralOrderService tIntegralOrderService; |
| | | |
| | | @Autowired |
| | | private ITUserService userService; |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Resource |
| | | private TEmailService emailService; |
| | | |
| | | @Resource |
| | | private ITSystemNoticeService systemNoticeService; |
| | | |
| | | @Resource |
| | | private ITIntegralGoodsService integralGoodsService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 跳转到积分兑换订单首页 |
| | |
| | | @RequestMapping("/lookDetail/{id}") |
| | | public String lookDetail(@PathVariable Integer id, Model model) { |
| | | TIntegralOrder tIntegralOrder = tIntegralOrderService.selectById(id); |
| | | model.addAttribute("str",tIntegralOrder.getRemark()); |
| | | model.addAttribute("str",tIntegralOrder.getManageRemark()); |
| | | return "/system/tComplaint/lookDetail.html"; |
| | | } |
| | | |
| | |
| | | tIntegralOrder.setState(2); |
| | | tIntegralOrder.setManageRemark(tIntegralOrder.getRemark()); |
| | | tIntegralOrder.setRemark(null); |
| | | |
| | | tIntegralOrderService.updateById(tIntegralOrder); |
| | | TIntegralOrder tIntegralOrder1 = tIntegralOrderService.selectById(tIntegralOrder.getId()); |
| | | TUser tUser = userService.selectById(tIntegralOrder1.getUserId()); |
| | | TIntegralGoods tIntegralGoods = integralGoodsService.selectById(tIntegralOrder1.getGoodsId()); |
| | | try { |
| | | Integer language = tUser.getLanguage(); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您使用" + tIntegralOrder1.getIntegral() + "积分成功兑换" + tIntegralGoods.getName() : |
| | | language == 2 ? "You redeemed " + tIntegralOrder1.getIntegral() + " points for the " + tIntegralGoods.getName() + " successfully" : |
| | | "Vous avez échangé " + tIntegralOrder1.getIntegral() + " points avec succès contre le " + tIntegralGoods.getName() + "", tIntegralOrder1.getUserId()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(ToolUtil.isNotEmpty(tUser.getEmail())){ |
| | | try { |
| | | Integer language = tUser.getLanguage(); |
| | | String nickName = tUser.getNickName(); |
| | | String email = tUser.getEmail(); |
| | | |
| | | String path = templatePath + "user/pointExchange.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("积分兑换已通过审核"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + nickName + ","); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Points redemption approved"); |
| | | Element user_chinese = document.getElementById("user_english"); |
| | | user_chinese.text("Hello " + nickName + ","); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Approbation de l’échange de points"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + nickName + ","); |
| | | } |
| | | EmailUtil.send(email, language == 1 ? "积分兑换已通过审核" : language == 2 ? "Points redemption approved" : "Approbation de l’échange de points", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/home/igotechgh/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/home/igotechgh/nginx/html/files/html/complaint_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | String link ="https://igo.i-go.group/files/html/complaint_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(tUser.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "积分兑换已通过审核" : language == 2 ? "Points redemption approved" : "Approbation de l’échange de points"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(language,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | }).start(); |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |