parent
343b0fb77f
commit
698a5b942e
@ -0,0 +1,176 @@ |
||||
package com.bweb.controller; |
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.SessionObject; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.dao.BsIntegralRebateMapper; |
||||
import com.hai.entity.ApiKfcStores; |
||||
import com.hai.entity.BsIntegralRebate; |
||||
import com.hai.entity.BsOperationLog; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.BsIntegralRebateService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
import java.util.Objects; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/bsIntegralRebate") |
||||
@Api(value = "积分返利") |
||||
public class BsIntegralRebateController { |
||||
private static Logger log = LoggerFactory.getLogger(BsIntegralRebateController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private BsIntegralRebateService bsIntegralRebateService; |
||||
|
||||
@RequestMapping(value = "/selectCompanyList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取公司列表") |
||||
public ResponseData selectCompanyList(@RequestParam(name = "type", required = false) Integer type, |
||||
@RequestParam(name = "productId", required = false) Long productId, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("type", type); |
||||
map.put("companyId", userInfoModel.getBsCompany().getId()); |
||||
|
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(bsIntegralRebateService.getIntegralRebateByList(map))); |
||||
} catch (Exception e) { |
||||
log.error("BsCompanyController --> selectCompanyList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/findIntegralRebateById", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询详情") |
||||
public ResponseData getOrderById(@RequestParam(name = "id", required = true) Long id) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(bsIntegralRebateService.findIntegralRebateById(id)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getOrderById() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/insertPrice", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "新增金额") |
||||
public ResponseData insertPrice(@RequestBody BsIntegralRebate integralRebate, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
if (integralRebate.getPercentage() == null || |
||||
integralRebate.getType() == null || |
||||
integralRebate.getProductId() == null |
||||
) { |
||||
log.error("OutRechargePriceController -> insertPrice() error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("type" , integralRebate.getType()); |
||||
map.put("productId" , integralRebate.getProductId()); |
||||
|
||||
BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); |
||||
|
||||
if (bsIntegralRebate != null) { |
||||
log.error("OutRechargePriceController -> insertPrice() error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已存在当前产品"); |
||||
} |
||||
|
||||
integralRebate.setCompanyId(userInfoModel.getBsCompany().getId()); |
||||
integralRebate.setCreateTime(new Date()); |
||||
integralRebate.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
integralRebate.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
integralRebate.setUpdateTime(new Date()); |
||||
integralRebate.setStatus(101); |
||||
|
||||
bsIntegralRebateService.insertIntegralRebate(integralRebate); |
||||
|
||||
return ResponseMsgUtil.success("新增成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("OutRechargePriceController --> insertPrice() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/updatePrice", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "修改金额") |
||||
public ResponseData updatePrice(@RequestBody BsIntegralRebate integralRebate, HttpServletRequest request) { |
||||
try { |
||||
|
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
if (integralRebate.getPercentage() == null || |
||||
integralRebate.getId() == null || |
||||
integralRebate.getType() == null || |
||||
integralRebate.getProductId() == null |
||||
) { |
||||
log.error("OutRechargePriceController -> insertPrice() error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("type" , integralRebate.getType()); |
||||
map.put("productId" , integralRebate.getProductId()); |
||||
|
||||
BsIntegralRebate bsIntegralRebate = bsIntegralRebateService.findIntegralRebateByMap(map); |
||||
|
||||
if (bsIntegralRebate != null && !Objects.equals(integralRebate.getId(), bsIntegralRebate.getId())) { |
||||
log.error("OutRechargePriceController -> insertPrice() error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已存在当前产品"); |
||||
} |
||||
|
||||
integralRebate.setOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
integralRebate.setOperatorId(userInfoModel.getSecUser().getId()); |
||||
integralRebate.setUpdateTime(new Date()); |
||||
integralRebate.setStatus(101); |
||||
|
||||
bsIntegralRebateService.updateIntegralRebate(integralRebate); |
||||
|
||||
return ResponseMsgUtil.success("修改成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("OutRechargePriceController --> insertPrice() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
@ -1,36 +1,76 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.BsIntegralRebateMapper; |
||||
import com.hai.entity.BsIntegralRebate; |
||||
import com.hai.entity.BsIntegralRebateExample; |
||||
import com.hai.service.BsIntegralRebateService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("bsIntegralRebateService") |
||||
public class BsIntegralRebateServiceImpl implements BsIntegralRebateService { |
||||
|
||||
@Resource |
||||
private BsIntegralRebateMapper bsIntegralRebateMapper; |
||||
|
||||
@Override |
||||
public BsIntegralRebate findIntegralRebateByMap(Map<String, Object> map) { |
||||
|
||||
BsIntegralRebateExample example = new BsIntegralRebateExample(); |
||||
BsIntegralRebateExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map , "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type")); |
||||
} |
||||
if (MapUtils.getLong(map , "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId")); |
||||
} |
||||
if (MapUtils.getLong(map , "productId") != null) { |
||||
criteria.andProductIdEqualTo(MapUtils.getLong(map , "productId")); |
||||
} |
||||
|
||||
List<BsIntegralRebate> list = bsIntegralRebateMapper.selectByExample(example); |
||||
|
||||
if (list.size() > 0) { |
||||
bsIntegralRebateMapper.selectByExample(example).get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BsIntegralRebate findIntegralRebateById(Long id) { |
||||
return null; |
||||
return bsIntegralRebateMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<BsIntegralRebate> getIntegralRebateByList(Map<String, Object> map) { |
||||
return null; |
||||
BsIntegralRebateExample example = new BsIntegralRebateExample(); |
||||
BsIntegralRebateExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getInteger(map , "type") != null) { |
||||
criteria.andTypeEqualTo(MapUtils.getInteger(map , "type")); |
||||
} |
||||
if (MapUtils.getLong(map , "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId")); |
||||
} |
||||
if (MapUtils.getLong(map , "productId") != null) { |
||||
criteria.andProductIdEqualTo(MapUtils.getLong(map , "productId")); |
||||
} |
||||
return bsIntegralRebateMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public void insertIntegralRebate(BsIntegralRebate bsIntegralRebate) { |
||||
|
||||
bsIntegralRebateMapper.insert(bsIntegralRebate); |
||||
} |
||||
|
||||
@Override |
||||
public void updateIntegralRebate(BsIntegralRebate bsIntegralRebate) { |
||||
|
||||
bsIntegralRebateMapper.updateByPrimaryKeySelective(bsIntegralRebate); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue