| | |
| | | import com.stylefeng.guns.modular.system.dao.UserCouponRecordMapper; |
| | | import com.stylefeng.guns.modular.system.model.UserCouponRecord; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.IUserCouponRecordService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.util.DateUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private ISystemNoticeService systemNoticeService; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryCoupon(Integer uid, Integer companyId, Integer state, Integer couponUseType, Double money, Integer pageNum, Integer size) throws Exception { |
| | | public List<Map<String, Object>> queryCoupon(Integer language, Integer uid, Integer companyId, Integer state, Integer couponUseType, Double money, Integer pageNum, Integer size) throws Exception { |
| | | pageNum = (pageNum - 1) * size; |
| | | return userCouponRecordMapper.queryCoupon(uid, companyId, state, couponUseType, money, pageNum, size); |
| | | List<Map<String, Object>> list = userCouponRecordMapper.queryCoupon(uid, companyId, state, couponUseType, money, pageNum, size); |
| | | for (Map<String, Object> map : list) { |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryMyCoupons(Integer state, Integer pageNum, Integer size, Integer uid) throws Exception { |
| | | public List<Map<String, Object>> queryMyCoupons(Integer language, Integer state, Integer pageNum, Integer size, Integer uid) throws Exception { |
| | | pageNum = (pageNum - 1) * size; |
| | | return userCouponRecordMapper.queryMyCoupons(state, pageNum, size, uid); |
| | | List<Map<String, Object>> list = userCouponRecordMapper.queryMyCoupons(state, pageNum, size, uid); |
| | | for (Map<String, Object> map : list) { |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(id); |
| | | if(userCouponRecord.getUserId().compareTo(uid) != 0){ |
| | | language = userInfoService.queryLanguage(uid, language); |
| | | return ResultUtil.error(language == 1 ? "您不能删除此优惠券" : language == 2 ? "You cannot delete this coupon" : "Vous ne pouvez pas supprimer ce coupon"); |
| | | return ResultUtil.error(language == 1 ? "您不能删除此优惠券" : language == 2 ? "You cannot cancel the coupon." : "Vous ne pouvez pas annuler le coupon."); |
| | | } |
| | | userCouponRecordMapper.deleteById(id); |
| | | return ResultUtil.success(); |
| | |
| | | public ResultUtil handselCoupon(Integer id, Integer uid, Integer userId, Integer language) throws Exception { |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(id); |
| | | language = userInfoService.queryLanguage(uid, language); |
| | | UserInfo userInfo1 = userInfoService.selectById(uid); |
| | | String nickName = userInfo1.getNickName(); |
| | | String phone = userInfo1.getPhone(); |
| | | if(userCouponRecord.getUserId().compareTo(uid) != 0){ |
| | | return ResultUtil.error(language == 1 ? "您不能赠送此优惠券" : language == 2 ? "You cannot gift this coupon" : "Vous ne pouvez pas offrir ce coupon"); |
| | | return ResultUtil.error(language == 1 ? "您不能赠送此优惠券" : language == 2 ? "You cannot gift the coupon." : "Vous ne pouvez pas offrir le coupon."); |
| | | } |
| | | if(userCouponRecord.getState() != 1){ |
| | | return ResultUtil.error(language == 1 ? "优惠券已无法使用" : language == 2 ? "Coupon no longer available" : "Le coupon n'est plus disponible"); |
| | | return ResultUtil.error(language == 1 ? "优惠券已无法使用" : language == 2 ? "The coupon is no more available." : "Le coupon n’est plus disponible."); |
| | | } |
| | | userCouponRecord.setUserId(userId); |
| | | userCouponRecordMapper.updateById(userCouponRecord); |
| | | UserInfo userInfo = userInfoService.selectById(userId); |
| | | Integer language1 = userInfo.getLanguage(); |
| | | systemNoticeService.addSystemNotice(1, language1 == 1 ? nickName + "(" + phone + ")刚赠送您了一张GHS 5.00的优惠券,请查看账户。" : language1 == 2 |
| | | ? nickName + "(" + phone + ")just gifted a GHS 5.00 coupon to you, please check your account." |
| | | : nickName + "(" + phone + ")vient de vous offrir un coupon de GHS 5.00, veuillez vérifier votre compte.", userId, 1); |
| | | return ResultUtil.success(); |
| | | } |
| | | |