parent
8eccefdc26
commit
7e3e0ad72b
@ -0,0 +1,94 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
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.DateUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighApprove; |
||||
import com.hai.entity.HighCouponHandsel; |
||||
import com.hai.entity.HighMerchant; |
||||
import com.hai.model.HighCouponModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighApproveService; |
||||
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.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @ClassName HighApproveController |
||||
* @Description: 审批操作 |
||||
* @Author 胡锐 |
||||
* @Date 2021/3/16 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value = "/coupon") |
||||
@Api(value = "卡卷接口") |
||||
public class HighApproveController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighApproveController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighApproveService highApproveService; |
||||
|
||||
@RequestMapping(value="/approveProcessed",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "审批") |
||||
public ResponseData approveProcessed(@RequestBody String reqBody, HttpServletRequest request) { |
||||
try { |
||||
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(reqBody); |
||||
Long approveId = jsonObject.getLong("approveId"); |
||||
Integer status = jsonObject.getInteger("status"); |
||||
String remarks = jsonObject.getString("remarks"); |
||||
if(approveId == null || status == null) { |
||||
log.error("HighCouponController -> approveProcessed() error!","参数错误"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询审批记录
|
||||
HighApprove approve = highApproveService.getApproveById(approveId); |
||||
if (approve == null) { |
||||
log.error("HighCouponController -> approveProcessed() error!","未找到审批记录"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_APPROVE, ""); |
||||
} |
||||
if (approve.getStatus() != 1) { |
||||
log.error("HighCouponController -> approveProcessed() error!","审批已处理"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.APPROVE_PROCESSED, ""); |
||||
} |
||||
|
||||
approve.setRemarks(remarks); |
||||
approve.setUpdateTime(new Date()); |
||||
approve.setApproveOperatorId(userInfoModel.getSecUser().getId()); |
||||
approve.setApproveOperatorName(userInfoModel.getSecUser().getUserName()); |
||||
highApproveService.approveProcessed(approve); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighCouponController -> approveProcessed() error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package com.hai.model; |
||||
|
||||
/** |
||||
* @ClassName HighCouponCodeModel |
||||
* @Description: |
||||
* @Author 胡锐 |
||||
* @Date 2021/3/16 |
||||
**/ |
||||
public interface HighCouponCodeModel { |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,60 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighCouponHandsel; |
||||
import com.hai.model.HighCouponHandselModel; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName HighCouponHandselService |
||||
* @Description: 赠送卡卷配置 |
||||
* @Author 胡锐 |
||||
* @Date 2021/3/16 |
||||
**/ |
||||
public interface HighCouponHandselService { |
||||
|
||||
/** |
||||
* |
||||
* @Title: insertCouponHandsel |
||||
* @Author 胡锐 |
||||
* @Description: 增加 |
||||
* @Date 11:02 2021/3/16 |
||||
* @Param [highCouponHandsel] |
||||
* @return void |
||||
**/ |
||||
void insertCouponHandsel(HighCouponHandsel highCouponHandsel); |
||||
|
||||
/** |
||||
* |
||||
* @Title: updateCouponHandsel |
||||
* @Author 胡锐 |
||||
* @Description: 修改 |
||||
* @Date 11:04 2021/3/16 |
||||
* @Param [highCouponHandsel] |
||||
* @return void |
||||
**/ |
||||
void updateCouponHandsel(HighCouponHandsel highCouponHandsel); |
||||
|
||||
/** |
||||
* |
||||
* @Title: getCouponHandselById |
||||
* @Author 胡锐 |
||||
* @Description: 根据id查询 |
||||
* @Date 11:06 2021/3/16 |
||||
* @Param [id] |
||||
* @return com.hai.model.HighCouponHandselModel |
||||
**/ |
||||
HighCouponHandselModel getCouponHandselById(Long id); |
||||
|
||||
/** |
||||
* |
||||
* @Title: getHandselListByCoupon |
||||
* @Author 胡锐 |
||||
* @Description: 根据卡卷 查询赠送配置列表 |
||||
* @Date 14:18 2021/3/16 |
||||
* @Param [couponId] |
||||
* @return java.util.List<com.hai.model.HighCouponHandselModel> |
||||
**/ |
||||
List<HighCouponHandselModel> getHandselListByCoupon(Long couponId); |
||||
} |
@ -0,0 +1,74 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighCouponHandselMapper; |
||||
import com.hai.entity.HighCoupon; |
||||
import com.hai.entity.HighCouponHandsel; |
||||
import com.hai.entity.HighCouponHandselExample; |
||||
import com.hai.model.HighCouponHandselModel; |
||||
import com.hai.service.HighCouponHandselService; |
||||
import com.hai.service.HighCouponService; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName HighCouponHandselServiceImpl |
||||
* @Description: TODO () |
||||
* @Author 胡锐 |
||||
* @Date 2021/3/16 |
||||
**/ |
||||
@Service("highCouponHandselService") |
||||
public class HighCouponHandselServiceImpl implements HighCouponHandselService { |
||||
|
||||
@Resource |
||||
private HighCouponHandselMapper highCouponHandselMapper; |
||||
|
||||
@Resource |
||||
private HighCouponService highCouponService; |
||||
|
||||
@Override |
||||
public void insertCouponHandsel(HighCouponHandsel highCouponHandsel) { |
||||
highCouponHandselMapper.insert(highCouponHandsel); |
||||
} |
||||
|
||||
@Override |
||||
public void updateCouponHandsel(HighCouponHandsel highCouponHandsel) { |
||||
highCouponHandselMapper.updateByPrimaryKey(highCouponHandsel); |
||||
} |
||||
|
||||
@Override |
||||
public HighCouponHandselModel getCouponHandselById(Long id) { |
||||
HighCouponHandsel handsel = highCouponHandselMapper.selectByPrimaryKey(id); |
||||
if (handsel != null) { |
||||
HighCouponHandselModel model = new HighCouponHandselModel(); |
||||
BeanUtils.copyProperties(handsel, model); |
||||
model.setHighCouponModel(highCouponService.getCouponDetail(handsel.getId())); |
||||
return model; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<HighCouponHandselModel> getHandselListByCoupon(Long couponId) { |
||||
HighCouponHandselExample example = new HighCouponHandselExample(); |
||||
example.createCriteria().andCouponIdEqualTo(couponId).andStatusEqualTo(1); |
||||
List<HighCouponHandsel> list = highCouponHandselMapper.selectByExample(example); |
||||
if (list != null && list.size() > 0) { |
||||
HighCouponHandselModel model; |
||||
List<HighCouponHandselModel> modelList = new ArrayList<>(); |
||||
for (HighCouponHandsel handsel : list) { |
||||
model = new HighCouponHandselModel(); |
||||
BeanUtils.copyProperties(handsel, model); |
||||
model.setHighCouponModel(highCouponService.getCouponDetail(handsel.getId())); |
||||
modelList.add(model); |
||||
} |
||||
return modelList; |
||||
} |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue