| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.UserCouponRecordMapper; |
| | | import com.stylefeng.guns.modular.system.model.UserCouponRecord; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | pageNum = (pageNum - 1) * size; |
| | | return userCouponRecordMapper.queryCoupon(uid, companyId, state, couponUseType, money, pageNum, size); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryCoupon1(Integer uid, String cityCode, Integer state, Integer couponUseType, Double money, Integer pageNum, Integer size) throws Exception { |
| | | if(null != pageNum && null != size){ |
| | | pageNum = (pageNum - 1) * size; |
| | | } |
| | | List<Map<String, Object>> list = userCouponRecordMapper.queryCoupon1(uid, cityCode, state, couponUseType, money, pageNum, size); |
| | | for (Map<String, Object> map : list) { |
| | | Object citys = map.get("citys"); |
| | | if(null != citys){ |
| | | List<String> names = new ArrayList<>(); |
| | | String s = citys.toString(); |
| | | JSONArray jsonArray = JSON.parseArray(s); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String name = jsonObject.getString("name"); |
| | | names.add(name); |
| | | } |
| | | map.put("citys", JSON.toJSONString(names)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 获取优惠券列表 |
| | | * @param state |
| | |
| | | @Override |
| | | public List<Map<String, Object>> queryMyCoupons(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) { |
| | | Object citys = map.get("citys"); |
| | | if(null != citys){ |
| | | List<String> names = new ArrayList<>(); |
| | | String s = citys.toString(); |
| | | JSONArray jsonArray = JSON.parseArray(s); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | String name = jsonObject.getString("name"); |
| | | names.add(name); |
| | | } |
| | | map.put("citys", JSON.toJSONString(names)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public ResultUtil delMyCoupon(Integer id, Integer uid) throws Exception { |
| | | UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(id); |
| | | if(userCouponRecord.getUserId() != uid){ |
| | | if(!userCouponRecord.getUserId().equals(uid)){ |
| | | return ResultUtil.error("您不能删除此优惠券"); |
| | | } |
| | | userCouponRecordMapper.deleteById(id); |