| | |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.AddressComponentsVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.TinggPayUtil; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest; |
| | | import com.stylefeng.guns.modular.system.warpper.LoginWarpper; |
| | | import com.stylefeng.guns.modular.taxi.model.PaymentRecord; |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | |
| | | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; |
| | | import org.apache.shiro.crypto.hash.Md5Hash; |
| | | import org.apache.shiro.util.ByteSource; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | private ISystemNoticeService systemNoticeService; |
| | | |
| | | @Autowired |
| | | private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Value("${callbackPath}") |
| | | private String callbackPath; |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | private String salt = "&a.s"; |
| | | |
| | |
| | | |
| | | //发送验证码短信 |
| | | redisUtil.setStrValue(phone, authCode, 5 * 60);//设置五分钟过期 |
| | | String templateCode = ""; |
| | | switch (type){ |
| | | case 1: |
| | | templateCode = "SMS_207770039";//身份验证 |
| | | break; |
| | | case 2: |
| | | templateCode = "SMS_207770039";//登录确认 |
| | | break; |
| | | case 3: |
| | | templateCode = "SMS_207770039";//用户注册 |
| | | break; |
| | | case 4: |
| | | templateCode = "SMS_207770039";//修改密码 |
| | | break; |
| | | } |
| | | /*String sData = aLiSendSms.sendSms(phone, templateCode, "{\"code\":\"" + authCode + "\"}"); |
| | | JSONObject jsonObject = JSON.parseObject(sData); |
| | | String message = jsonObject.getString("Message"); |
| | | if(!"OK".equals(message)){ |
| | | System.err.println(message); |
| | | return ResultUtil.error(message); |
| | | }*/ |
| | | SMSUtil.send_huawei_sms("b793ae3d41a049059197bfe92cf8bc83", "+" + phone, "[\"" + authCode + "\"]"); |
| | | System.out.println(sms); |
| | | } |
| | | |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, String registAreaCode,Integer uid,Integer type, Integer userType) throws Exception { |
| | | public ResultUtil<LoginWarpper> captchaLogin(String phone, String code, String registIp, Double lat, Double lng,Integer uid,Integer type, |
| | | Integer userType, Integer language) throws Exception { |
| | | boolean b = this.checkCaptcha(phone, code); |
| | | if(!b){ |
| | | return ResultUtil.error("验证码无效"); |
| | | return ResultUtil.error(language == 1 ? "验证码无效" : language == 2 ? "Invalid captcha" : "Code de vérification invalide"); |
| | | } |
| | | |
| | | UserInfo userInfo = userInfoMapper.queryByPhone(phone); |
| | |
| | | userInfo.setState(1); |
| | | |
| | | //用户所属企业 |
| | | if(null != registAreaCode){ |
| | | Company query = companyCityService.query(registAreaCode); |
| | | if(null != lat && null != lng){ |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lat); |
| | | AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos(); |
| | | String[] citys = new String[addressComponentsVos.length]; |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | citys[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | Company query = companyCityService.query(citys); |
| | | userInfo.setCompanyId(null != query ? query.getId() : null); |
| | | userInfo.setRegistAreaCode(registAreaCode); |
| | | userInfo.setRegistAreaCode(null); |
| | | }else{ |
| | | userInfo.setCompanyId(1); |
| | | } |
| | |
| | | |
| | | this.insert(userInfo); |
| | | |
| | | this.addCoupon(userInfo);//添加优惠券 |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/register.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + userInfo.getNickName() + ","); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_english = document.getElementById("user_english"); |
| | | user_english.text("Hello " + userInfo.getNickName() + ","); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + userInfo.getNickName() + ","); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "注册成功" : language == 2 ? "Successful registration" : "Inscription réussie", document.html()); |
| | | } |
| | | |
| | | this.addCoupon(userInfo, language);//添加优惠券 |
| | | if(null != uid){ |
| | | if(type == 2){//司机分享 |
| | | Driver driver = driverMapper.selectById(uid); |
| | |
| | | driver.setLaveActivityMoney(bigDecimal.add(new BigDecimal(driver.getLaveActivityMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(bigDecimal.add(new BigDecimal(driver.getBalance())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverMapper.updateById(driver); |
| | | |
| | | if(ToolUtil.isNotEmpty(driver.getEmail())){ |
| | | String path1 = templatePath + "driver/index.html"; |
| | | Document document1 = Jsoup.parse(new File(path1), "UTF-8"); |
| | | if(1 == language){ |
| | | document1.getElementById("english").attr("style", "display: none;"); |
| | | document1.getElementById("french").attr("style", "display: none;"); |
| | | document1.getElementById("invite").attr("style", "display: none;"); |
| | | document1.getElementById("settle").attr("style", "display: none;"); |
| | | document1.getElementById("pass").attr("style", "display: none;"); |
| | | document1.getElementById("bill").attr("style", "display: none;"); |
| | | document1.getElementById("reward").attr("style", "display: none;"); |
| | | document1.getElementById("rewardToday").attr("style", "display: none;"); |
| | | |
| | | Element user_user = document1.getElementById("user_user"); |
| | | user_user.text("您好 " + driver.getName() + ","); |
| | | Element user_content = document1.getElementById("user_content"); |
| | | user_content.text("您已成功邀请一位用户注册I-GO,获得奖励GHS " + bigDecimal.doubleValue() + ",请查收"); |
| | | } |
| | | if(2 == language){ |
| | | document1.getElementById("chinese").attr("style", "display: none;"); |
| | | document1.getElementById("french").attr("style", "display: none;"); |
| | | document1.getElementById("invite1").attr("style", "display: none;"); |
| | | document1.getElementById("settle1").attr("style", "display: none;"); |
| | | document1.getElementById("pass1").attr("style", "display: none;"); |
| | | document1.getElementById("bill1").attr("style", "display: none;"); |
| | | document1.getElementById("reward1").attr("style", "display: none;"); |
| | | document1.getElementById("rewardToday1").attr("style", "display: none;"); |
| | | |
| | | Element user1_user = document1.getElementById("user1_user"); |
| | | user1_user.text("Hello " + driver.getName() + ","); |
| | | Element user1_content = document1.getElementById("user1_content"); |
| | | user1_content.text("You have succeeded to invite a rider to register with I-GO, so you received a GHS " + bigDecimal.doubleValue() + " bonus, please check your balance."); |
| | | } |
| | | if(3 == language){ |
| | | document1.getElementById("chinese").attr("style", "display: none;"); |
| | | document1.getElementById("english").attr("style", "display: none;"); |
| | | document1.getElementById("invite1").attr("style", "display: none;"); |
| | | document1.getElementById("settle1").attr("style", "display: none;"); |
| | | document1.getElementById("pass1").attr("style", "display: none;"); |
| | | document1.getElementById("bill1").attr("style", "display: none;"); |
| | | document1.getElementById("reward1").attr("style", "display: none;"); |
| | | document1.getElementById("rewardToday1").attr("style", "display: none;"); |
| | | |
| | | Element user2_user = document1.getElementById("user2_user"); |
| | | user2_user.text("Bonjour " + driver.getName() + ","); |
| | | Element user2_content = document1.getElementById("user2_content"); |
| | | user2_content.text("Vous avez invité avec succès un utilisateur à s’inscrire à i-go pour recevoir une récompense GHS " + bigDecimal.doubleValue() + ". Veuillez vérifier"); |
| | | } |
| | | EmailUtil.send(driver.getEmail(), language == 1 ? "邀请奖励" : language == 2 ? "invitation bonus" : "prime d'invitation", document1.html()); |
| | | } |
| | | } |
| | | if(type == 1){//用户分享 |
| | | UserInfo userInfo1 = userInfoMapper.selectById(uid); |
| | |
| | | Date date = new Date(); |
| | | for(Map<String, Object> map : query){ |
| | | Double lavePrice = Double.valueOf(map.get("lavePrice").toString()); |
| | | String startTime = map.get("startTime").toString(); |
| | | String endTime = map.get("endTime").toString(); |
| | | int num = 0; |
| | | for(int i = Integer.valueOf(String.valueOf(map.get("totalNum"))); i > 0; i--){ |
| | | //判断当前优惠券金额是否大于可发放剩余总金额 |
| | | if(Double.valueOf(String.valueOf(map.get("money"))).compareTo(lavePrice) > 0){ |
| | |
| | | userCouponRecordService.insert(userCouponRecord); |
| | | //修改剩余可发放总金额 |
| | | lavePrice -= Double.valueOf(String.valueOf(map.get("money"))); |
| | | num++; |
| | | } |
| | | UserActivityInvite uai = userActivityInviteMapper.selectById(Integer.valueOf(map.get("id").toString())); |
| | | uai.setLavePrice(new BigDecimal(lavePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | userActivityInviteMapper.updateById(uai); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo1.getEmail())){ |
| | | String path1 = templatePath + "user/coupon.html"; |
| | | Document document1 = Jsoup.parse(new File(path1), "UTF-8"); |
| | | if(language == 1){ |
| | | document1.getElementById("english").attr("style", "display: none;"); |
| | | document1.getElementById("french").attr("style", "display: none;"); |
| | | Element chinese_user = document1.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo1.getNickName() + ","); |
| | | Element chinese_number = document1.getElementById("chinese_number"); |
| | | chinese_number.text("您有" + num + "张优惠券到账"); |
| | | Element chinese_date = document1.getElementById("chinese_date"); |
| | | chinese_date.text("此活动有效期在" + startTime + "至" + endTime + ",详情请查看I-GO平台"); |
| | | } |
| | | if(language == 2){ |
| | | document1.getElementById("chinese").attr("style", "display: none;"); |
| | | document1.getElementById("french").attr("style", "display: none;"); |
| | | Element english_user = document1.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo1.getNickName() + ","); |
| | | Element english_number = document1.getElementById("english_number"); |
| | | english_number.text("You have received " + num + " coupons"); |
| | | Element english_date = document1.getElementById("english_date"); |
| | | english_date.text("You could use them from" + startTime + "to" + endTime); |
| | | } |
| | | if(language == 3){ |
| | | document1.getElementById("chinese").attr("style", "display: none;"); |
| | | document1.getElementById("english").attr("style", "display: none;"); |
| | | Element french_user = document1.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo1.getNickName() + ","); |
| | | Element french_number = document1.getElementById("french_number"); |
| | | french_number.text("Vous avez " + num + " coupons à recevoir"); |
| | | Element french_date = document1.getElementById("french_date"); |
| | | french_date.text("Cette promotion est valide du" + startTime + "au" + endTime); |
| | | } |
| | | EmailUtil.send(userInfo1.getEmail(), language == 1 ? "优惠券到账" : language == 2 ? "Coupon arrives" : "Le coupon arrive", document1.html()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | UserInfo finalUserInfo = userInfo; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.baseInfoPassenger(finalUserInfo.getId()); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | } |
| | | if(userInfo.getState() == 2){ |
| | | return ResultUtil.error("账号被冻结"); |
| | |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setEmergencyContact(userInfo.getEmergencyContact()); |
| | | loginWarpper.setEmergencyContactNumber(userInfo.getEmergencyContactNumber()); |
| | | loginWarpper.setEmail(userInfo.getEmail()); |
| | | |
| | | smsrecordService.saveData(1, phone, code, "短信验证码【" + code + "】已发到您的手机,验证码将在5分钟后失效,请及时登录!"); |
| | | return ResultUtil.success(loginWarpper); |
| | | } |
| | | |
| | | @Override |
| | | public synchronized ResultUtil<LoginWarpper> captchaLogin(String phone, String code, Integer uid, Integer type, Integer userType) throws Exception { |
| | | ResultUtil<LoginWarpper> resultUtil = this.captchaLogin(phone, code, null, null,uid,type,userType); |
| | | public synchronized ResultUtil<LoginWarpper> captchaLogin(String phone, String code, Integer uid, Integer type, Integer userType, Integer language) throws Exception { |
| | | ResultUtil<LoginWarpper> resultUtil = this.captchaLogin(phone, code, null, null, null,uid,type,userType,language); |
| | | |
| | | return resultUtil; |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil<LoginWarpper> userLogin(String phone, String password) throws Exception { |
| | | public ResultUtil<LoginWarpper> userLogin(String phone, String password, Integer language) throws Exception { |
| | | UserInfo userInfo = this.queryByPhone(phone); |
| | | if(null == userInfo){ |
| | | return ResultUtil.error("账号无效"); |
| | | return ResultUtil.error(language == 1 ? "账号无效" : language == 2 ? "Invalid account" : "Compte non valide"); |
| | | } |
| | | if(userInfo.getState() == 2){ |
| | | return ResultUtil.error("账号被冻结"); |
| | | return ResultUtil.error(language == 1 ? "账号被冻结" : language == 2 ? "Account is frozen." : "Le compte est gelé"); |
| | | } |
| | | if(!ShiroKit.md5(password, salt).equals(userInfo.getPassWord())){ |
| | | return ResultUtil.error("密码错误"); |
| | | return ResultUtil.error(language == 1 ? "密码错误" : language == 2 ? "Password error" : "Mot de passe incorrect"); |
| | | } |
| | | |
| | | //调用单点登录的逻辑 |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil<LoginWarpper> wxLogin(Integer type, String openid, String unionid, String jscode, String registIp, |
| | | String registAreaCode, Integer sex, String nickName, String avatar,String loginType,String encryptedData, String iv,Integer uid) throws Exception { |
| | | String registAreaCode, Integer sex, String nickName, String avatar,String loginType, |
| | | String encryptedData, String iv,Integer uid, Integer language) throws Exception { |
| | | UserInfo userInfo = null; |
| | | String phone=null; |
| | | if(type == 2){//小程序 |
| | |
| | | userInfo.setConsumption(0D); |
| | | userInfo.setBalance(0D); |
| | | userInfo.setState(1); |
| | | //用户所属企业 |
| | | if(null != registAreaCode){ |
| | | Company query = companyCityService.query(registAreaCode); |
| | | userInfo.setCompanyId(null != query ? query.getId() : null); |
| | | userInfo.setRegistAreaCode(registAreaCode); |
| | | } |
| | | userInfo.setCompanyId(1); |
| | | this.insert(userInfo); |
| | | |
| | | this.addCoupon(userInfo);//添加优惠券 |
| | | |
| | | UserInfo finalUserInfo = userInfo; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.baseInfoPassenger(finalUserInfo.getId()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/register.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + userInfo.getNickName() + ","); |
| | | } |
| | | }).start(); |
| | | if(2 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_english = document.getElementById("user_english"); |
| | | user_english.text("Hello " + userInfo.getNickName() + ","); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + userInfo.getNickName() + ","); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "注册成功" : language == 2 ? "Successful registration" : "Inscription réussie", document.html()); |
| | | } |
| | | |
| | | |
| | | this.addCoupon(userInfo, language);//添加优惠券 |
| | | |
| | | } |
| | | if(userInfo.getState() == 2){ |
| | | return ResultUtil.error("账号被冻结"); |
| | |
| | | loginWarpper.setToken(token); |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setPhone(ToolUtil.isNotEmpty(userInfo.getPhone()) ? 2 : 1); |
| | | loginWarpper.setEmail(ToolUtil.isNotEmpty(userInfo.getEmail()) ? 2 : 1); |
| | | loginWarpper.setEmail(userInfo.getEmail()); |
| | | loginWarpper.setEmergencyContact(userInfo.getEmergencyContact()); |
| | | loginWarpper.setEmergencyContactNumber(userInfo.getEmergencyContactNumber()); |
| | | if(uid!=null){ |
| | |
| | | Date date = new Date(); |
| | | for(Map<String, Object> map : query){ |
| | | Double lavePrice = Double.valueOf(map.get("lavePrice").toString()); |
| | | String startTime = map.get("startTime").toString(); |
| | | String endTime = map.get("endTime").toString(); |
| | | int num = 0; |
| | | for(int i = Integer.valueOf(String.valueOf(map.get("totalNum"))); i > 0; i--){ |
| | | //判断当前优惠券金额是否大于可发放剩余总金额 |
| | | if(Double.valueOf(String.valueOf(map.get("money"))).compareTo(lavePrice) > 0){ |
| | |
| | | userCouponRecordService.insert(userCouponRecord); |
| | | //修改剩余可发放总金额 |
| | | lavePrice -= Double.valueOf(String.valueOf(map.get("money"))); |
| | | num++; |
| | | } |
| | | UserActivityInvite uai = userActivityInviteMapper.selectById(Integer.valueOf(map.get("id").toString())); |
| | | uai.setLavePrice(new BigDecimal(lavePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | userActivityInviteMapper.updateById(uai); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/coupon.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(language == 1){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element chinese_user = document.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo.getNickName() + ","); |
| | | Element chinese_number = document.getElementById("chinese_number"); |
| | | chinese_number.text("您有" + num + "张优惠券到账"); |
| | | Element chinese_date = document.getElementById("chinese_date"); |
| | | chinese_date.text("此活动有效期在" + startTime + "至" + endTime + ",详情请查看I-GO平台"); |
| | | } |
| | | if(language == 2){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_number = document.getElementById("english_number"); |
| | | english_number.text("You have received " + num + " coupons"); |
| | | Element english_date = document.getElementById("english_date"); |
| | | english_date.text("You could use them from" + startTime + "to" + endTime); |
| | | } |
| | | if(language == 3){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element french_user = document.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo.getNickName() + ","); |
| | | Element french_number = document.getElementById("french_number"); |
| | | french_number.text("Vous avez " + num + " coupons à recevoir"); |
| | | Element french_date = document.getElementById("french_date"); |
| | | french_date.text("Cette promotion est valide du" + startTime + "au" + endTime); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "优惠券到账" : language == 2 ? "Coupon arrives" : "Le coupon arrive", document.html()); |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(loginWarpper); |
| | |
| | | loginWarpper.setToken(token); |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setPhone(ToolUtil.isNotEmpty(userInfo.getPhone()) ? 2 : 1); |
| | | loginWarpper.setEmail(ToolUtil.isNotEmpty(userInfo.getEmail()) ? 2 : 1); |
| | | loginWarpper.setEmail(userInfo.getEmail()); |
| | | loginWarpper.setEmergencyContact(userInfo.getEmergencyContact()); |
| | | loginWarpper.setEmergencyContactNumber(userInfo.getEmergencyContactNumber()); |
| | | return ResultUtil.success(loginWarpper); |
| | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil facebookLogin(String id, String name, String email, String registAreaCode, Integer uid) throws Exception { |
| | | public ResultUtil facebookLogin(String id, String name, String email, Double lat, Double lng, Integer uid, Integer language) throws Exception { |
| | | UserInfo userInfo = this.selectOne(new EntityWrapper<UserInfo>().eq("faceBookId", id).ne("flag", 3)); |
| | | if(null == userInfo){ |
| | | userInfo = new UserInfo(); |
| | |
| | | userInfo.setuType(1); |
| | | } |
| | | //用户所属企业 |
| | | if(null != registAreaCode){ |
| | | Company query = companyCityService.query(registAreaCode); |
| | | userInfo.setCompanyId(null != query ? query.getId() : null); |
| | | userInfo.setRegistAreaCode(registAreaCode); |
| | | if(null != lat && null != lng){ |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lng); |
| | | if(null != reverseGeocode){ |
| | | AddressComponentsVo[] addressComponentsVos = reverseGeocode.getAddressComponentsVos(); |
| | | String[] citys = new String[addressComponentsVos.length]; |
| | | for (int i = 0; i < addressComponentsVos.length; i++) { |
| | | citys[i] = addressComponentsVos[i].getLongName(); |
| | | } |
| | | Company query = companyCityService.query(citys); |
| | | userInfo.setCompanyId(null != query ? query.getId() : null); |
| | | userInfo.setRegistAreaCode(null); |
| | | } |
| | | |
| | | } |
| | | this.insert(userInfo); |
| | | |
| | | this.addCoupon(userInfo);//添加优惠券 |
| | | |
| | | UserInfo finalUserInfo = userInfo; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.baseInfoPassenger(finalUserInfo.getId()); |
| | | } |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/register.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + userInfo.getNickName() + ","); |
| | | } |
| | | }).start(); |
| | | if(2 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_english = document.getElementById("user_english"); |
| | | user_english.text("Hello " + userInfo.getNickName() + ","); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + userInfo.getNickName() + ","); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "注册成功" : language == 2 ? "Successful registration" : "Inscription réussie", document.html()); |
| | | } |
| | | |
| | | |
| | | this.addCoupon(userInfo, language);//添加优惠券 |
| | | } |
| | | |
| | | if(userInfo.getState() == 2){ |
| | |
| | | loginWarpper.setToken(token); |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setPhone(ToolUtil.isNotEmpty(userInfo.getPhone()) ? 2 : 1); |
| | | loginWarpper.setEmail(ToolUtil.isNotEmpty(userInfo.getEmail()) ? 2 : 1); |
| | | loginWarpper.setEmail(userInfo.getEmail()); |
| | | loginWarpper.setEmergencyContact(userInfo.getEmergencyContact()); |
| | | loginWarpper.setEmergencyContactNumber(userInfo.getEmergencyContactNumber()); |
| | | if(uid!=null){ |
| | |
| | | Date date = new Date(); |
| | | for(Map<String, Object> map : query){ |
| | | Double lavePrice = Double.valueOf(map.get("lavePrice").toString()); |
| | | String startTime = map.get("startTime").toString(); |
| | | String endTime = map.get("endTime").toString(); |
| | | int num = 0; |
| | | for(int i = Integer.valueOf(String.valueOf(map.get("totalNum"))); i > 0; i--){ |
| | | //判断当前优惠券金额是否大于可发放剩余总金额 |
| | | if(Double.valueOf(String.valueOf(map.get("money"))).compareTo(lavePrice) > 0){ |
| | |
| | | userCouponRecordService.insert(userCouponRecord); |
| | | //修改剩余可发放总金额 |
| | | lavePrice -= Double.valueOf(String.valueOf(map.get("money"))); |
| | | num++; |
| | | } |
| | | UserActivityInvite uai = userActivityInviteMapper.selectById(Integer.valueOf(map.get("id").toString())); |
| | | uai.setLavePrice(new BigDecimal(lavePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | userActivityInviteMapper.updateById(uai); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/coupon.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(language == 1){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element chinese_user = document.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo.getNickName() + ","); |
| | | Element chinese_number = document.getElementById("chinese_number"); |
| | | chinese_number.text("您有" + num + "张优惠券到账"); |
| | | Element chinese_date = document.getElementById("chinese_date"); |
| | | chinese_date.text("此活动有效期在" + startTime + "至" + endTime + ",详情请查看I-GO平台"); |
| | | } |
| | | if(language == 2){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_number = document.getElementById("english_number"); |
| | | english_number.text("You have received " + num + " coupons"); |
| | | Element english_date = document.getElementById("english_date"); |
| | | english_date.text("You could use them from" + startTime + "to" + endTime); |
| | | } |
| | | if(language == 3){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element french_user = document.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo.getNickName() + ","); |
| | | Element french_number = document.getElementById("french_number"); |
| | | french_number.text("Vous avez " + num + " coupons à recevoir"); |
| | | Element french_date = document.getElementById("french_date"); |
| | | french_date.text("Cette promotion est valide du" + startTime + "au" + endTime); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "优惠券到账" : language == 2 ? "Coupon arrives" : "Le coupon arrive", document.html()); |
| | | } |
| | | } |
| | | } |
| | | return ResultUtil.success(loginWarpper); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil forgetPassword(String phone, String code, String password) throws Exception { |
| | | boolean b = this.checkCaptcha(phone, code); |
| | | if(!b){ |
| | | return ResultUtil.error("验证码无效"); |
| | | } |
| | | public ResultUtil forgetPassword(String phone, String code, String password, Integer language) throws Exception { |
| | | UserInfo userInfo = this.queryByPhone(phone); |
| | | if(null == userInfo){ |
| | | return ResultUtil.error("手机号码未注册"); |
| | | return ResultUtil.error(language == 1 ? "手机号码未注册" : language == 2 ? "Cell phone number is not registered" : "Numéro de téléphone portable non enregistré"); |
| | | } |
| | | boolean b = this.checkCaptcha(phone, code); |
| | | if(!b){ |
| | | b = this.checkCaptcha(userInfo.getEmail(), code); |
| | | } |
| | | if(!b){ |
| | | return ResultUtil.error(language == 1 ? "验证码无效" : language == 2 ? "Invalid captcha" : "Code de vérification invalide"); |
| | | } |
| | | if(userInfo.getState() == 2){ |
| | | return ResultUtil.error("账号已被冻结"); |
| | | return ResultUtil.error(language == 1 ? "账号已被冻结" : language == 2 ? "The account has been frozen" : "Le compte a été gelé"); |
| | | } |
| | | userInfo.setPassWord(ShiroKit.md5(password, salt)); |
| | | userInfo.setUpdateUser(userInfo.getId()); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil bindingPhone(Integer uid, String phone, String code) throws Exception { |
| | | public ResultUtil bindingPhone(Integer uid, String phone, String code, Integer language) throws Exception { |
| | | boolean b = this.checkCaptcha(phone, code); |
| | | if(!b){ |
| | | return ResultUtil.error("验证码无效"); |
| | | return ResultUtil.error(language == 1 ? "验证码无效" : language == 2 ? "Invalid captcha" : "Code de vérification invalide"); |
| | | } |
| | | UserInfo userInfo = this.selectById(uid); |
| | | UserInfo userInfo1 = userInfoMapper.queryByPhone(phone); |
| | |
| | | loginWarpper.setToken(token); |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setPhone(2); |
| | | loginWarpper.setEmail(2); |
| | | loginWarpper.setEmail(userInfo1.getEmail()); |
| | | return ResultUtil.success(loginWarpper); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil bindingEmail(Integer uid, Integer type, String email, String code) throws Exception { |
| | | public ResultUtil bindingEmail(Integer uid, Integer type, String email, String code, Integer language) throws Exception { |
| | | boolean b = this.checkCaptcha(email, code); |
| | | if(!b){ |
| | | return ResultUtil.error("验证码无效"); |
| | | return ResultUtil.error(language == 1 ? "验证码无效" : language == 2 ? "Invalid captcha" : "Code de vérification invalide"); |
| | | } |
| | | UserInfo userInfo = this.selectById(uid); |
| | | UserInfo userInfo1 = userInfoMapper.queryByEmail(email); |
| | | if(null != userInfo1){ |
| | | userInfo1.setOpenId(userInfo.getOpenId()); |
| | | userInfo1.setUnionid(userInfo.getUnionid()); |
| | | userInfo1.setAppletsOpenId(userInfo.getAppletsOpenId()); |
| | | userInfo1.setAvatar(userInfo.getAvatar()); |
| | | userInfo1.setSex(userInfo.getSex()); |
| | | userInfo1.setNickName(userInfo.getNickName()); |
| | | this.updateById(userInfo1); |
| | | |
| | | this.deleteById(userInfo.getId());//删除原有数据 |
| | | //还原之前账号领取的注册优惠券 |
| | | List<UserCouponRecord> list = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("userId", userInfo.getId())); |
| | | for(UserCouponRecord ucr : list){ |
| | | if(ucr.getActivityType() == 1){//赠送 |
| | | |
| | | } |
| | | if(ucr.getActivityType() == 2){//注册 |
| | | UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectById(ucr.getCouponActivityId()); |
| | | userActivityRegistered.setLaveNum(userActivityRegistered.getLaveNum() + 1); |
| | | userActivityRegistered.setLavePrice(userActivityRegistered.getLavePrice() + ucr.getMoney()); |
| | | userActivityRegisteredService.updateById(userActivityRegistered); |
| | | } |
| | | if(ucr.getActivityType() == 3){//邀请 |
| | | |
| | | } |
| | | if(ucr.getActivityType() == 4){//充值 |
| | | |
| | | } |
| | | userCouponRecordService.deleteById(ucr.getId()); |
| | | } |
| | | |
| | | |
| | | //获取新的token等数据 |
| | | String token = this.getToken(userInfo1, ""); |
| | | LoginWarpper loginWarpper = new LoginWarpper(); |
| | | loginWarpper.setId(userInfo1.getId()); |
| | | loginWarpper.setToken(token); |
| | | loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | loginWarpper.setPhone(2); |
| | | loginWarpper.setEmail(2); |
| | | return ResultUtil.success(loginWarpper); |
| | | if(null != userInfo1 && uid.compareTo(userInfo1.getId()) != 0){ |
| | | return ResultUtil.error(language == 1 ? "邮箱已被使用" : language == 2 ? "The mailbox is in use" : "La boîte mail a déjà été utilisée"); |
| | | } |
| | | |
| | | // if(null != userInfo1){ |
| | | // userInfo1.setOpenId(userInfo.getOpenId()); |
| | | // userInfo1.setUnionid(userInfo.getUnionid()); |
| | | // userInfo1.setAppletsOpenId(userInfo.getAppletsOpenId()); |
| | | // userInfo1.setAvatar(userInfo.getAvatar()); |
| | | // userInfo1.setSex(userInfo.getSex()); |
| | | // userInfo1.setNickName(userInfo.getNickName()); |
| | | // this.updateById(userInfo1); |
| | | // |
| | | // this.deleteById(userInfo.getId());//删除原有数据 |
| | | // //还原之前账号领取的注册优惠券 |
| | | // List<UserCouponRecord> list = userCouponRecordService.selectList(new EntityWrapper<UserCouponRecord>().eq("userId", userInfo.getId())); |
| | | // for(UserCouponRecord ucr : list){ |
| | | // if(ucr.getActivityType() == 1){//赠送 |
| | | // |
| | | // } |
| | | // if(ucr.getActivityType() == 2){//注册 |
| | | // UserActivityRegistered userActivityRegistered = userActivityRegisteredService.selectById(ucr.getCouponActivityId()); |
| | | // userActivityRegistered.setLaveNum(userActivityRegistered.getLaveNum() + 1); |
| | | // userActivityRegistered.setLavePrice(userActivityRegistered.getLavePrice() + ucr.getMoney()); |
| | | // userActivityRegisteredService.updateById(userActivityRegistered); |
| | | // } |
| | | // if(ucr.getActivityType() == 3){//邀请 |
| | | // |
| | | // } |
| | | // if(ucr.getActivityType() == 4){//充值 |
| | | // |
| | | // } |
| | | // userCouponRecordService.deleteById(ucr.getId()); |
| | | // } |
| | | // |
| | | // |
| | | // //获取新的token等数据 |
| | | // String token = this.getToken(userInfo1, ""); |
| | | // LoginWarpper loginWarpper = new LoginWarpper(); |
| | | // loginWarpper.setId(userInfo1.getId()); |
| | | // loginWarpper.setToken(token); |
| | | // loginWarpper.setAppid(UUIDUtil.getRandomCode()); |
| | | // loginWarpper.setPhone(2); |
| | | // loginWarpper.setEmail(userInfo1.getEmail()); |
| | | // return ResultUtil.success(loginWarpper); |
| | | // } |
| | | |
| | | userInfo.setEmail(email); |
| | | userInfo.setUpdateTime(new Date()); |
| | | userInfo.setUpdateUser(userInfo.getId()); |
| | | this.updateById(userInfo); |
| | | if(type == 1){//注册成功后发送邮件 |
| | | EmailUtil.getMimeMessage(email, "注册账户", ""); |
| | | } |
| | | // if(type == 1){//注册成功后发送邮件 |
| | | //// EmailUtil.getMimeMessage(email, "注册账户", ""); |
| | | // } |
| | | return ResultUtil.success(new LoginWarpper()); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil depositBalance(Integer payType, Double money, Integer uid, Integer type) throws Exception { |
| | | public ResultUtil depositBalance(Integer payType, String accountNumber, Double money, Integer uid, Integer type, Integer language) throws Exception { |
| | | UserInfo userInfo = userInfoMapper.selectById(uid); |
| | | if(money.compareTo(0D) <= 0){ |
| | | return ResultUtil.error("支付金额必须大于0元"); |
| | | } |
| | | if(payType == 1){//微信支付 |
| | | Integer integer = paymentRecordService.saveData(2, uid, 1, null, null, 1, money, "", 1);//添加预支付数据 |
| | | //Map<String, String> map = icbcPayUtil.placeAnOrder(integer.toString(), 9, 5, uid.toString(), "余额充值", money, callbackPath + "/base/wxCancelUserBalance", uid.toString(), type, userInfo.getAppletsOpenId()); |
| | | ResultUtil resultUtil = payMoneyUtil.weixinpay("余额充值",integer.toString(),integer.toString(),money+"","/base/wxCancelUserBalance","JSAPI",userInfo.getAppletsOpenId()); |
| | | if(resultUtil.getCode()==200){ |
| | | PaymentRecord paymentRecord = paymentRecordService.selectById(integer); |
| | | paymentRecordService.updateById(paymentRecord); |
| | | return resultUtil; |
| | | }else{ |
| | | return ResultUtil.error("获取支付信息失败", ""); |
| | | } |
| | | // ResultUtil resultUtil = payMoneyUtil.weixinpay("余额充值",language.toString(),integer.toString(),money+"","/base/wxCancelUserBalance","JSAPI",userInfo.getAppletsOpenId()); |
| | | // if(resultUtil.getCode()==200){ |
| | | // PaymentRecord paymentRecord = paymentRecordService.selectById(integer); |
| | | // paymentRecordService.updateById(paymentRecord); |
| | | // return resultUtil; |
| | | // }else{ |
| | | // return ResultUtil.error("获取支付信息失败", ""); |
| | | // } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String merchantTransactionId = sdf.format(new Date()) + language + integer; |
| | | CheckoutRequest checkoutRequest = new CheckoutRequest(); |
| | | checkoutRequest.setMsisdn(Long.valueOf(userInfo.getPhone())); |
| | | checkoutRequest.setCustomerEmail(userInfo.getEmail()); |
| | | checkoutRequest.setAccountNumber(accountNumber); |
| | | checkoutRequest.setCustomerFirstName(userInfo.getFirstName()); |
| | | checkoutRequest.setCustomerLastName(userInfo.getLastName()); |
| | | checkoutRequest.setRequestAmount(money); |
| | | checkoutRequest.setMerchantTransactionId(merchantTransactionId); |
| | | checkoutRequest.setRequestDescription("Account top-up"); |
| | | checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelUserBalance"); |
| | | checkoutRequest.setPendingRedirectUrl(""); |
| | | checkoutRequest.setSuccessRedirectUrl("https://10pz685243.zicp.fun"); |
| | | checkoutRequest.setFailRedirectUrl("https://www.baidu.com"); |
| | | return TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | |
| | | |
| | | } |
| | | if(payType == 2){//支付宝支付 |
| | | Integer integer = paymentRecordService.saveData(2, uid, 1, null, null, 2, money, "", 1);//添加预支付数据 |
| | | ResultUtil resultUtil = payMoneyUtil.alipay("余额充值","余额充值",integer.toString(),money+"","/base/aliCancelUserBalance"); |
| | | if(resultUtil.getCode()==200){ |
| | | PaymentRecord paymentRecord = paymentRecordService.selectById(integer); |
| | | paymentRecordService.updateById(paymentRecord); |
| | | return resultUtil; |
| | | }else{ |
| | | return ResultUtil.error("获取支付信息失败", ""); |
| | | } |
| | | } |
| | | // if(payType == 2){//支付宝支付 |
| | | // Integer integer = paymentRecordService.saveData(2, uid, 1, null, null, 2, money, "", 1);//添加预支付数据 |
| | | // ResultUtil resultUtil = payMoneyUtil.alipay("余额充值","余额充值",integer + "_" + language,money+"","/base/aliCancelUserBalance"); |
| | | // if(resultUtil.getCode()==200){ |
| | | // PaymentRecord paymentRecord = paymentRecordService.selectById(integer); |
| | | // paymentRecordService.updateById(paymentRecord); |
| | | // return resultUtil; |
| | | // }else{ |
| | | // return ResultUtil.error("获取支付信息失败", ""); |
| | | // } |
| | | // } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil updatePhone(String code, String phone, Integer uid) throws Exception { |
| | | public ResultUtil updatePhone(String code, String phone, Integer uid, Integer language) throws Exception { |
| | | boolean b = this.checkCaptcha(phone, code); |
| | | if(!b){ |
| | | return ResultUtil.error("验证码无效"); |
| | | return ResultUtil.error(language == 1 ? "验证码无效" : language == 2 ? "Invalid captcha" : "Code de vérification invalide"); |
| | | } |
| | | UserInfo userInfo = this.selectById(uid); |
| | | UserInfo userInfo1 = userInfoMapper.queryByPhone(phone); |
| | | if(null != userInfo1){ |
| | | return ResultUtil.error("手机号已被注册"); |
| | | return ResultUtil.error(language == 1 ? "手机号已被注册" : language == 2 ? "The phone number has been registered" : "Le numéro de téléphone a été enregistré"); |
| | | } |
| | | userInfo.setPhone(phone); |
| | | this.updateById(userInfo); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil updatePass(String password, Integer uid) throws Exception { |
| | | public ResultUtil updatePass(String password, Integer uid, Integer language) throws Exception { |
| | | UserInfo userInfo = this.selectById(uid); |
| | | userInfo.setPassWord(ShiroKit.md5(password, salt)); |
| | | this.updateById(userInfo); |
| | | //发送邮件 |
| | | EmailUtil.getMimeMessage(userInfo.getEmail(), "修改密码", ""); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/passwordReset.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + userInfo.getNickName() + ","); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element user_chinese = document.getElementById("user_english"); |
| | | user_chinese.text("Hello " + userInfo.getNickName() + ","); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + userInfo.getNickName() + ","); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "重置密码" : language == 2 ? "Reset password" : "Réinitialiser le mot de passe", document.html()); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void updateInfo(String avatar, String nickname, Integer sex, Date birthday, Integer uid) throws Exception { |
| | | public void updateInfo(String avatar, String nickname, Integer sex, Date birthday, String email, String lastName, String firstName, Integer uid) throws Exception { |
| | | UserInfo userInfo = this.selectById(uid); |
| | | if(ToolUtil.isNotEmpty(avatar)){ |
| | | userInfo.setAvatar(avatar); |
| | |
| | | } |
| | | if(null != birthday){ |
| | | userInfo.setBirthday(birthday); |
| | | } |
| | | if(null != email){ |
| | | userInfo.setEmail(email); |
| | | } |
| | | if(null != lastName){ |
| | | userInfo.setLastName(lastName); |
| | | } |
| | | if(null != firstName){ |
| | | userInfo.setFirstName(firstName); |
| | | } |
| | | this.updateById(userInfo); |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void payCancelUserBalance(Integer id, String order_id, Integer paymentRecordId, Integer type) throws Exception { |
| | | public void payCancelUserBalance(Integer id, String order_id, Integer paymentRecordId, Integer type, Integer language) throws Exception { |
| | | PaymentRecord query = paymentRecordService.selectById(paymentRecordId); |
| | | UserInfo userInfo = this.selectById(query.getUserId()); |
| | | if(null != query){ |
| | |
| | | query.setState(2); |
| | | paymentRecordService.updateById(query); |
| | | |
| | | this.addCoupon(userInfo.getId(), query.getAmount(), userInfo.getCompanyId(), query.getId());//添加优惠券 |
| | | this.addCoupon(userInfo.getId(), query.getAmount(), userInfo.getCompanyId(), query.getId(), language);//添加优惠券 |
| | | |
| | | }else{ |
| | | System.err.println("预支付数据异常(userId = " + id + ")"); |
| | |
| | | * @param companyId |
| | | * @throws Exception |
| | | */ |
| | | public synchronized void addCoupon(Integer userId, Double money, Integer companyId, Integer paymentRecordId) throws Exception{ |
| | | public synchronized void addCoupon(Integer userId, Double money, Integer companyId, Integer paymentRecordId, Integer language) throws Exception{ |
| | | List<Map<String, Object>> query = userActivityBalanceService.query(money, companyId); |
| | | List<UserCouponRecord> list = new ArrayList<>(); |
| | | for(Map<String, Object> map : query){ |
| | | //添加通用优惠券 |
| | | Double lavePrice = Double.valueOf(String.valueOf(map.get("lavePrice"))); |
| | | String startTime = map.get("startTime").toString(); |
| | | String endTime = map.get("endTime").toString(); |
| | | if(null != map.get("bcompanyId")){ |
| | | for(int i = 0; i < Integer.valueOf(String.valueOf(map.get("generalNum"))); i++){ |
| | | //判断当前发放的优惠券是否大于剩余总发放金额 |
| | |
| | | |
| | | if(list.size() > 0){ |
| | | userCouponRecordService.insertBatch(list); |
| | | |
| | | UserInfo userInfo = userInfoMapper.selectById(userId); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/coupon.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(language == 1){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element chinese_user = document.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo.getNickName() + ","); |
| | | Element chinese_number = document.getElementById("chinese_number"); |
| | | chinese_number.text("您有" + list.size() + "张优惠券到账"); |
| | | Element chinese_date = document.getElementById("chinese_date"); |
| | | chinese_date.text("此活动有效期在" + startTime + "至" + endTime + ",详情请查看I-GO平台"); |
| | | } |
| | | if(language == 2){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_number = document.getElementById("english_number"); |
| | | english_number.text("You have received " + list.size() + " coupons"); |
| | | Element english_date = document.getElementById("english_date"); |
| | | english_date.text("You could use them from" + startTime + "to" + endTime); |
| | | } |
| | | if(language == 3){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element french_user = document.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo.getNickName() + ","); |
| | | Element french_number = document.getElementById("french_number"); |
| | | french_number.text("Vous avez " + list.size() + " coupons à recevoir"); |
| | | Element french_date = document.getElementById("french_date"); |
| | | french_date.text("Cette promotion est valide du" + startTime + "au" + endTime); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "优惠券到账" : language == 2 ? "Coupon arrives" : "Le coupon arrive", document.html()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public String getDefaultName(){ |
| | | int num = this.selectCount(new EntityWrapper<UserInfo>().ne("flag", 3)) + 1000001; |
| | | return "XW" + String.valueOf(num).substring(1); |
| | | return "IGO" + String.valueOf(num).substring(1); |
| | | } |
| | | |
| | | |
| | |
| | | * @param userInfo |
| | | * @throws Exception |
| | | */ |
| | | private synchronized void addCoupon(UserInfo userInfo) throws Exception{ |
| | | private synchronized void addCoupon(UserInfo userInfo, Integer language) throws Exception{ |
| | | //添加优惠券 |
| | | List<Map<String, Object>> list = userActivityRegisteredService.query(userInfo.getCompanyId()); |
| | | int num = 0; |
| | |
| | | if(null != map){ |
| | | Integer totalNum = Integer.valueOf(String.valueOf(map.get("totalNum"))); |
| | | Double lavePrice = Double.valueOf(String.valueOf(map.get("lavePrice"))); |
| | | String startTime = map.get("startTime").toString(); |
| | | String endTime = map.get("endTime").toString(); |
| | | for(int i = totalNum; i > 0; i--){ |
| | | //判断当前发放的优惠券是否大于剩余可发送总金额 |
| | | if(Double.valueOf(String.valueOf(map.get("money"))).compareTo(lavePrice) > 0){ |
| | |
| | | UserActivityRegistered uar = userActivityRegisteredService.selectById(Integer.valueOf(map.get("id").toString())); |
| | | uar.setLavePrice(new BigDecimal(lavePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | userActivityRegisteredService.updateById(uar); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/coupon.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(language == 1){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element chinese_user = document.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo.getNickName() + ","); |
| | | Element chinese_number = document.getElementById("chinese_number"); |
| | | chinese_number.text("您有" + num + "张优惠券到账"); |
| | | Element chinese_date = document.getElementById("chinese_date"); |
| | | chinese_date.text("此活动有效期在" + startTime + "至" + endTime + ",详情请查看I-GO平台"); |
| | | } |
| | | if(language == 2){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | Element english_number = document.getElementById("english_number"); |
| | | english_number.text("You have received " + num + " coupons"); |
| | | Element english_date = document.getElementById("english_date"); |
| | | english_date.text("You could use them from" + startTime + "to" + endTime); |
| | | } |
| | | if(language == 3){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | Element french_user = document.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo.getNickName() + ","); |
| | | Element french_number = document.getElementById("french_number"); |
| | | french_number.text("Vous avez " + list.size() + " coupons à recevoir"); |
| | | Element french_date = document.getElementById("french_date"); |
| | | french_date.text("Cette promotion est valide du" + startTime + "au" + endTime); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "优惠券到账" : language == 2 ? "Coupon arrives" : "Le coupon arrive", document.html()); |
| | | } |
| | | } |
| | | } |
| | | //添加系统消息 |
| | |
| | | public Integer getAppOpenInfo(Integer type) { |
| | | return userInfoMapper.getAppOpenInfo(type); |
| | | } |
| | | |
| | | @Override |
| | | public Integer queryLanguage(Integer uid, Integer language) { |
| | | UserInfo userInfo = this.selectById(uid); |
| | | if(null != userInfo.getLanguage()){ |
| | | language = userInfo.getLanguage(); |
| | | } |
| | | if(null == language){ |
| | | language = 2; |
| | | } |
| | | return language; |
| | | } |
| | | } |