| | |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | 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.IUserCouponRecordService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Resource |
| | | private UserCouponRecordMapper userCouponRecordMapper; |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | |
| | | /** |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil delMyCoupon(Integer id, Integer uid) throws Exception { |
| | | public ResultUtil delMyCoupon(Integer id, Integer uid, Integer language) throws Exception { |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(id); |
| | | if(userCouponRecord.getUserId() != uid){ |
| | | return ResultUtil.error("您不能删除此优惠券"); |
| | | language = userInfoService.queryLanguage(uid, language); |
| | | return ResultUtil.error(language == 1 ? "您不能删除此优惠券" : language == 2 ? "You cannot delete this coupon" : "Vous ne pouvez pas supprimer ce coupon"); |
| | | } |
| | | userCouponRecordMapper.deleteById(id); |
| | | return ResultUtil.success(); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil handselCoupon(Integer id, Integer uid, Integer userId) throws Exception { |
| | | public ResultUtil handselCoupon(Integer id, Integer uid, Integer userId, Integer language) throws Exception { |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(id); |
| | | language = userInfoService.queryLanguage(uid, language); |
| | | if(userCouponRecord.getUserId() != uid){ |
| | | return ResultUtil.error("您不能赠送此优惠券"); |
| | | return ResultUtil.error(language == 1 ? "您不能赠送此优惠券" : language == 2 ? "You cannot gift this coupon" : "Vous ne pouvez pas offrir ce coupon"); |
| | | } |
| | | if(userCouponRecord.getState() != 1){ |
| | | return ResultUtil.error("优惠券已无法使用"); |
| | | return ResultUtil.error(language == 1 ? "优惠券已无法使用" : language == 2 ? "Coupon no longer available" : "Le coupon n'est plus disponible"); |
| | | } |
| | | userCouponRecord.setUserId(userId); |
| | | userCouponRecordMapper.updateById(userCouponRecord); |