| | |
| | | import com.dsh.activity.feignclient.account.model.TStoreStaff; |
| | | import com.dsh.activity.feignclient.model.CouponExamineListSearch; |
| | | import com.dsh.activity.feignclient.model.CouponListOfSearch; |
| | | import com.dsh.activity.feignclient.other.RegionClient; |
| | | import com.dsh.activity.feignclient.other.StoreClient; |
| | | import com.dsh.activity.feignclient.other.model.CityDataAndProvinceDataVo; |
| | | import com.dsh.activity.feignclient.other.model.Store; |
| | | import com.dsh.activity.model.CouponListVo; |
| | | import com.dsh.activity.model.request.CommodityRequest; |
| | |
| | | |
| | | @Resource |
| | | private StoreClient stoClient; |
| | | |
| | | |
| | | @Resource |
| | | private RegionClient regionClient; |
| | | |
| | | @Resource |
| | | private CouponStoreService couStoreService; |
| | |
| | | JSONObject jsonObject = JSON.parseObject(coupon.getContent()); |
| | | switch (coupon.getType()){ |
| | | case 1: |
| | | couponInfo.put("num1",jsonObject.getDouble("num1")); |
| | | couponInfo.put("num2",jsonObject.getDouble("num2")); |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | couponInfo.put("num1",jsonObject.getDouble("conditionalAmount")); |
| | | couponInfo.put("num2",jsonObject.getDouble("deductionAmount")); |
| | | break; |
| | | case 2: |
| | | couponInfo.put("num1",jsonObject.getDouble("num1")); |
| | | couponInfo.put("num1",jsonObject.getDouble("conditionalAmount")); |
| | | break; |
| | | case 3: |
| | | couponInfo.put("num1",jsonObject.getString("num1")); |
| | | couponInfo.put("num1",jsonObject.getString("experienceName")); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | coupon.setType(dataVo.getPrescription()); |
| | | HashMap<String, Object> stringObjectHashMap = new HashMap<>(); |
| | | switch (dataVo.getPrescription()){ |
| | | // {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} |
| | | case 1: |
| | | stringObjectHashMap.put("num1",dataVo.getCondition()); |
| | | stringObjectHashMap.put("num2",dataVo.getSubtraction()); |
| | | stringObjectHashMap.put("conditionalAmount",dataVo.getCondition()); |
| | | stringObjectHashMap.put("deductionAmount",dataVo.getSubtraction()); |
| | | coupon.setContent(stringObjectHashMap.toString()); |
| | | break; |
| | | case 2: |
| | | stringObjectHashMap.put("num1",dataVo.getDiscount()); |
| | | stringObjectHashMap.put("conditionalAmount",dataVo.getDiscount()); |
| | | coupon.setContent(stringObjectHashMap.toString()); |
| | | break; |
| | | case 3: |
| | | stringObjectHashMap.put("num1",dataVo.getExperience()); |
| | | stringObjectHashMap.put("experienceName",dataVo.getExperience()); |
| | | coupon.setContent(stringObjectHashMap.toString()); |
| | | break; |
| | | default: |
| | |
| | | if (dataVo.getUserType() == 1){ |
| | | coupon.setCityManagerId(dataVo.getCityManagerId()); |
| | | } |
| | | return couponService.save(coupon); |
| | | boolean save = couponService.save(coupon); |
| | | if (save){ |
| | | if (dataVo.getCompany() == 2){ |
| | | for (Integer storeId : dataVo.getStoreIds()) { |
| | | CouponStore couponStore = new CouponStore(); |
| | | couponStore.setCouponId(coupon.getId()); |
| | | couponStore.setStoreId(storeId); |
| | | couStoreService.save(couponStore); |
| | | } |
| | | } |
| | | List<Integer> cityIds = dataVo.getCityIds(); |
| | | if (dataVo.getCompany() == 3 && cityIds.size() > 0 ){ |
| | | List<CityDataAndProvinceDataVo> cityAndProvince = regionClient.getCityAndProvince(cityIds); |
| | | for (CityDataAndProvinceDataVo cityId : cityAndProvince) { |
| | | CouponCity couponCity = new CouponCity(); |
| | | couponCity.setCouponId(coupon.getId()); |
| | | couponCity.setCityCode(cityId.getCityCode()); |
| | | couponCity.setCity(cityId.getCityName()); |
| | | couponCity.setProvinceCode(cityId.getProvinceCode()); |
| | | couponCity.setProvince(cityId.getProvinceName()); |
| | | cityService.save(couponCity); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | }catch (Exception e){ |
| | | return false; |
| | | } |