puzhibing
2023-05-18 53562814add61acfdc02d6b25dae6324f6fd5f92
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserCouponRecordServiceImpl.java
@@ -3,8 +3,11 @@
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;
@@ -17,6 +20,9 @@
    @Resource
    private UserCouponRecordMapper userCouponRecordMapper;
    @Autowired
    private IUserInfoService userInfoService;
    /**
@@ -68,10 +74,11 @@
     * @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();
@@ -87,13 +94,14 @@
     * @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);