|
@@ -3,14 +3,23 @@ package com.iamberry.rst.controllers.address;
|
|
import com.iamberry.rst.core.address.City;
|
|
import com.iamberry.rst.core.address.City;
|
|
import com.iamberry.rst.core.address.District;
|
|
import com.iamberry.rst.core.address.District;
|
|
import com.iamberry.rst.core.address.Province;
|
|
import com.iamberry.rst.core.address.Province;
|
|
|
|
+import com.iamberry.rst.core.cm.SalesOrder;
|
|
|
|
+import com.iamberry.rst.core.order.Product;
|
|
|
|
+import com.iamberry.rst.core.order.ProductType;
|
|
|
|
+import com.iamberry.rst.core.page.PagedResult;
|
|
import com.iamberry.rst.faces.address.AddressService;
|
|
import com.iamberry.rst.faces.address.AddressService;
|
|
|
|
+import com.iamberry.rst.utils.StitchAttrUtil;
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
import com.iamberry.wechat.tools.ResponseJson;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -81,4 +90,217 @@ public class AddressController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 地址列表
|
|
|
|
+ * @param request
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("address:list:address")
|
|
|
|
+ @RequestMapping("/listProvinces")
|
|
|
|
+ public ModelAndView productPage(HttpServletRequest request, Province province,
|
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10", required = false) Integer pageSize,
|
|
|
|
+ @RequestParam(value = "pageNO", defaultValue = "1", required = false) Integer pageNO,
|
|
|
|
+ @RequestParam(value = "totalNum", defaultValue = "0", required = false) Integer totalNum) {
|
|
|
|
+ ModelAndView mv = new ModelAndView("address/address_list");
|
|
|
|
+
|
|
|
|
+ PagedResult<Province> pagedResult = addressService.listProvinces(pageNO, pageSize, province, totalNum == 0);
|
|
|
|
+ if (totalNum != 0){
|
|
|
|
+ pagedResult.setTotal(totalNum);
|
|
|
|
+ }
|
|
|
|
+ StitchAttrUtil.getSa()
|
|
|
|
+ .setModelAndView(province, mv, "/address/listProvinces", pagedResult);
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入添加市页面
|
|
|
|
+ * @param provinceId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/to_add_city")
|
|
|
|
+ public ModelAndView to_add_city(@RequestParam("provinceId") Integer provinceId) {
|
|
|
|
+ return new ModelAndView("address/add_city").addObject("provinceId", provinceId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入添加区页面
|
|
|
|
+ * @param cityId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/to_add_district")
|
|
|
|
+ public ModelAndView to_add_district(@RequestParam("cityId") Integer cityId) {
|
|
|
|
+ return new ModelAndView("address/add_district").addObject("cityId", cityId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加区
|
|
|
|
+ * @param district
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/add_district")
|
|
|
|
+ public ResponseJson addDistrict(District district) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "添加成功", 200);
|
|
|
|
+ if(district.getCityId() == null || district.getDistrict() == null || district.getPostcode() == null){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ district.setDivisionCode(district.getDistrictId());
|
|
|
|
+ Integer num = addressService.addDistrict(district);
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加市
|
|
|
|
+ * @param city
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/add_city")
|
|
|
|
+ public ResponseJson addDistrict(City city) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "添加成功", 200);
|
|
|
|
+ if(city.getCityId() == null || city.getProvinceId() == null || city.getCity() == null){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ Integer num = addressService.addCity(city);
|
|
|
|
+ city.setDivisionCode(city.getCityId());
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除市
|
|
|
|
+ * @param cityId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/detect_city")
|
|
|
|
+ public ResponseJson detect_city(HttpServletRequest request,Integer cityId) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "删除成功", 200);
|
|
|
|
+ if(cityId == null || cityId.equals("")){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ Integer num = addressService.delCity(cityId);
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除区
|
|
|
|
+ * @param districtId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/del_district")
|
|
|
|
+ public ResponseJson delDistrict(Integer districtId) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "删除成功", 200);
|
|
|
|
+ if(districtId == null || districtId.equals("")){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ Integer num = addressService.delDistrict(districtId);
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入修改区页面
|
|
|
|
+ * @param districtId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/to_update_district")
|
|
|
|
+ public ModelAndView to_update_district(@RequestParam("districtId") Integer districtId) {
|
|
|
|
+ District district = new District();
|
|
|
|
+ district.setDistrictId(districtId);
|
|
|
|
+ List<District> districts = addressService.listDistrict(district);
|
|
|
|
+ return new ModelAndView("address/update_district").addObject("district", districts.get(0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 进入修改市页面
|
|
|
|
+ * @param cityId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/to_update_city")
|
|
|
|
+ public ModelAndView to_update_city(@RequestParam("cityId") Integer cityId) {
|
|
|
|
+ City city = new City();
|
|
|
|
+ city.setCityId(cityId);
|
|
|
|
+ List<City> citys = addressService.listCity(city);
|
|
|
|
+ return new ModelAndView("address/update_city").addObject("city", citys.get(0));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改区
|
|
|
|
+ * @param district
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/updateDistrict")
|
|
|
|
+ public ResponseJson updateDistrict(District district) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "修改成功", 200);
|
|
|
|
+ if(district == null || district.getDistrictId() == null){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ Integer num = addressService.updateDistrict(district);
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 修改市
|
|
|
|
+ * @param city
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "/update_city")
|
|
|
|
+ public ResponseJson update_city(City city) throws Exception {
|
|
|
|
+ ResponseJson rj =new ResponseJson(200, "修改成功", 200);
|
|
|
|
+ if(city == null || city.getCityId() == null|| city.getCity() == null){
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ Integer num = addressService.updateCity(city);
|
|
|
|
+ if (num < 1) {
|
|
|
|
+ rj.setResultCode(500);
|
|
|
|
+ rj.setReturnCode(500);
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+ return rj;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|