Commit 73d79054 by duanhq

订单审核,发货 v 1.2.0

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21681 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 41096af3
...@@ -43,4 +43,28 @@ public interface CommonClient { ...@@ -43,4 +43,28 @@ public interface CommonClient {
*/ */
@RequestMapping(value="/carservice/publicservice/common/checkVerifyCode", method= RequestMethod.GET) @RequestMapping(value="/carservice/publicservice/common/checkVerifyCode", method= RequestMethod.GET)
public JSONObject checkVerifyCode(@RequestParam("phone")String phone,@RequestParam("verifyCode")String verifyCode); public JSONObject checkVerifyCode(@RequestParam("phone")String phone,@RequestParam("verifyCode")String verifyCode);
/**
*
* @author duanht
* @Title: sendIndentCheckPass
* @Description: TODO 发送订货单审核通过短信
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/common/sendIndentCheckPassSms", method= RequestMethod.GET)
public JSONObject sendIndentCheckPassSms(@RequestParam("phone")String phone,@RequestParam("indentNo")String indentNo);
/**
*
* @author duanht
* @Title: sendDeviceSms
* @Description: TODO 发送订单已发货短信
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/common/sendDeviceSms", method= RequestMethod.GET)
public JSONObject sendDeviceSms(@RequestParam("phone")String phone,@RequestParam("indentNo")String indentNo);
} }
...@@ -6,6 +6,12 @@ import java.util.Map; ...@@ -6,6 +6,12 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.validation.groups.Default; import javax.validation.groups.Default;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.feign.client.CommonClient;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysReceiveAddress;
import com.glsx.ordercenter.service.ReceiveAddressService;
import com.glsx.ordercenter.utils.KdApiUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -41,6 +47,12 @@ public class IndentController extends BaseController{ ...@@ -41,6 +47,12 @@ public class IndentController extends BaseController{
@Autowired @Autowired
private IndentService indentService; private IndentService indentService;
@Autowired
private ReceiveAddressService receiveAddressService;
@Autowired
private CommonClient commonClient;
@AuthCheck @AuthCheck
@RequestMapping(value="/add", method=RequestMethod.POST) @RequestMapping(value="/add", method=RequestMethod.POST)
public ResultObject add(HttpServletRequest request, @Validated(value = {Default.class}) SysIndent indent, BindingResult bindingResult) { public ResultObject add(HttpServletRequest request, @Validated(value = {Default.class}) SysIndent indent, BindingResult bindingResult) {
...@@ -70,4 +82,90 @@ public class IndentController extends BaseController{ ...@@ -70,4 +82,90 @@ public class IndentController extends BaseController{
ResultObject result = indentService.update(indent); ResultObject result = indentService.update(indent);
return result; return result;
} }
/**
* @author xiaoyj
* @param request
* @return ResultObject
* @Description 编辑收货地址列表
*/
@RequestMapping(value = "/editReceiveAdress", method = RequestMethod.POST)
public ResultObject editReceiveAdress(HttpServletRequest request,SysReceiveAddress sysReceiveAddress) {
int result=receiveAddressService.editReceiveAdress(sysReceiveAddress);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
}
/**
* @author xiaoyj
* @param request
* @return ResultObject
* @Description 删除收货地址
*/
@RequestMapping(value = "/deleteReceiveAdress", method = RequestMethod.POST)
public ResultObject deleteReceiveAdress(HttpServletRequest request,SysReceiveAddress sysReceiveAddress) {
int result=receiveAddressService.deleteReceiveAdress(sysReceiveAddress);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @param request
* @param expCode 快递公司编码
* @param expNo 快递单号
* @return ResultObject
*/
@RequestMapping(value = "/catLogisticsTrail ", method = RequestMethod.POST)
public ResultObject catLogisticsTrail(HttpServletRequest request,String expCode, String expNo) {
KdApiUtil kdApiUtil=new KdApiUtil();
try {
String result=kdApiUtil.getOrderTracesByJson(expCode,expNo);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg(),result);
} catch (Exception e) {
logger.info("物流信息查询异常");
}
return new ResultObject(ResultCodeEnum.ERROR.getCode(),ResultCodeEnum.ERROR.getMsg());
}
/**
*
* @param request
* @return ResultObject
* @Description 订货单审核通过
*/
@RequestMapping(value = "/checkDevice", method = RequestMethod.POST)
public ResultObject checkDevice(HttpServletRequest request, Integer id) {
Integer userId = UserUtils.getUserId(request);
int result = indentService.checkDevice(id,userId);
//发送短信提示审核通过
if(result == 1){
SysIndent sysIndent = indentService.selectByPrimaryKey(id);
JSONObject obj = commonClient.sendIndentCheckPassSms(sysIndent.getPhone(), sysIndent.getIndentNo());
if (obj != null && obj.getIntValue("code") != com.glsx.common.constants.ResultCodeEnum.SUCCESS.getCode()) {
return new ResultObject(obj.getIntValue("code"), obj.getString("message"));
}
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @param request
* @return ResultObject
*@Description 发货
*/
@RequestMapping(value = "/sendDevice", method = RequestMethod.POST)
public ResultObject sendDevice(HttpServletRequest request, SysIndentLogistics sysIndentLogistics) {
Integer userId = UserUtils.getUserId(request);
Integer result = indentService.sendDevice(userId,sysIndentLogistics);
//发送短信提示已发货
if(result != null ){
SysIndent sysIndent = indentService.selectByPrimaryKey(sysIndentLogistics.getIndentId());
JSONObject obj = commonClient.sendDeviceSms(sysIndent.getPhone(), sysIndent.getIndentNo());
if (obj != null && obj.getIntValue("code") != com.glsx.common.constants.ResultCodeEnum.SUCCESS.getCode()) {
return new ResultObject(obj.getIntValue("code"), obj.getString("message"));
}
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg());
}
} }
...@@ -24,7 +24,7 @@ public class DeviceRepertoryReq { ...@@ -24,7 +24,7 @@ public class DeviceRepertoryReq {
/** /**
* 在途库存 * 在途库存
*/ */
private Integer shipmentNum; private Integer sendDeviceNum;
/** /**
* 下属技工库存 * 下属技工库存
...@@ -63,12 +63,12 @@ public class DeviceRepertoryReq { ...@@ -63,12 +63,12 @@ public class DeviceRepertoryReq {
this.serviceDeviceNum = serviceDeviceNum; this.serviceDeviceNum = serviceDeviceNum;
} }
public Integer getShipmentNum() { public Integer getSendDeviceNum() {
return shipmentNum; return sendDeviceNum;
} }
public void setShipmentNum(Integer shipmentNum) { public void setSendDeviceNum(Integer sendDeviceNum) {
this.shipmentNum = shipmentNum; this.sendDeviceNum = sendDeviceNum;
} }
public Integer getMechanicDeviceNum() { public Integer getMechanicDeviceNum() {
......
package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import com.glsx.ordercenter.pojo.SysIndentLogisticsExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysIndentLogisticsMapper {
long countByExample(SysIndentLogisticsExample example);
int deleteByExample(SysIndentLogisticsExample example);
int deleteByPrimaryKey(Integer id);
int insert(SysIndentLogistics record);
int insertSelective(SysIndentLogistics record);
List<SysIndentLogistics> selectByExample(SysIndentLogisticsExample example);
SysIndentLogistics selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") SysIndentLogistics record, @Param("example") SysIndentLogisticsExample example);
int updateByExample(@Param("record") SysIndentLogistics record, @Param("example") SysIndentLogisticsExample example);
int updateByPrimaryKeySelective(SysIndentLogistics record);
int updateByPrimaryKey(SysIndentLogistics record);
}
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter.mapper; package com.glsx.ordercenter.mapper;
import com.glsx.ordercenter.pojo.SysIndent; import com.glsx.ordercenter.pojo.SysIndent;
import org.apache.ibatis.annotations.Param;
public interface SysIndentMapper { public interface SysIndentMapper {
...@@ -17,4 +18,6 @@ public interface SysIndentMapper { ...@@ -17,4 +18,6 @@ public interface SysIndentMapper {
int updateByPrimaryKey(SysIndent record); int updateByPrimaryKey(SysIndent record);
int getIndentCount(SysIndent indent); int getIndentCount(SysIndent indent);
Integer getSendDeviceNum(@Param("userId")Integer userId);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.ordercenter.pojo;
import java.util.Date;
public class SysIndentLogistics {
private Integer id;
private Integer indentId;
private String logisticsNo;
private String logisticsUnicode;
private Date logisticsTime;
private String remark;
private Integer createBy;
private Date createTime;
private Integer updateBy;
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getIndentId() {
return indentId;
}
public void setIndentId(Integer indentId) {
this.indentId = indentId;
}
public String getLogisticsNo() {
return logisticsNo;
}
public void setLogisticsNo(String logisticsNo) {
this.logisticsNo = logisticsNo == null ? null : logisticsNo.trim();
}
public String getLogisticsUnicode() {
return logisticsUnicode;
}
public void setLogisticsUnicode(String logisticsUnicode) {
this.logisticsUnicode = logisticsUnicode == null ? null : logisticsUnicode.trim();
}
public Date getLogisticsTime() {
return logisticsTime;
}
public void setLogisticsTime(Date logisticsTime) {
this.logisticsTime = logisticsTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
public Integer getCreateBy() {
return createBy;
}
public void setCreateBy(Integer createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getUpdateBy() {
return updateBy;
}
public void setUpdateBy(Integer updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -4,6 +4,7 @@ import javax.servlet.http.HttpServletRequest;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.ordercenter.pojo.SysIndent; import com.glsx.ordercenter.pojo.SysIndent;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
/** /**
* *
...@@ -40,4 +41,31 @@ public interface IndentService { ...@@ -40,4 +41,31 @@ public interface IndentService {
*/ */
ResultObject update(SysIndent indent); ResultObject update(SysIndent indent);
/**
*
* @author duanht
* @Title: sendDevice
* @Description: TODO 服务商发货
* @param userId,sysIndentLogistics
*
*/
Integer sendDevice(Integer userId,SysIndentLogistics sysIndentLogistics);
/**
*
* @author duanht
* @Title: checkDevice
* @Description: TODO 订货单审核通过
*
*/
int checkDevice(Integer id,Integer userId);
/**
*
* @author duanht
* @Title: selectByPrimaryKey
* @Description: TODO 根据id查订货单信息
*
*/
SysIndent selectByPrimaryKey(Integer id);
} }
...@@ -5,6 +5,7 @@ import com.glsx.ordercenter.dto.DeviceRepertoryReq; ...@@ -5,6 +5,7 @@ import com.glsx.ordercenter.dto.DeviceRepertoryReq;
import com.glsx.ordercenter.dto.MechanicRepertoryReq; import com.glsx.ordercenter.dto.MechanicRepertoryReq;
import com.glsx.ordercenter.mapper.SysDeviceMapper; import com.glsx.ordercenter.mapper.SysDeviceMapper;
import com.glsx.ordercenter.mapper.SysDeviceRepertoryMapper; import com.glsx.ordercenter.mapper.SysDeviceRepertoryMapper;
import com.glsx.ordercenter.mapper.SysIndentMapper;
import com.glsx.ordercenter.pojo.SysDevice; import com.glsx.ordercenter.pojo.SysDevice;
import com.glsx.ordercenter.pojo.SysDeviceRepertory; import com.glsx.ordercenter.pojo.SysDeviceRepertory;
import com.glsx.ordercenter.service.DeviceRepertoryService; import com.glsx.ordercenter.service.DeviceRepertoryService;
...@@ -29,7 +30,10 @@ import java.util.Map; ...@@ -29,7 +30,10 @@ import java.util.Map;
public class DeviceRepertoryServiceImpl implements DeviceRepertoryService { public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
@Autowired @Autowired
SysDeviceRepertoryMapper sysDeviceRepertoryMapper; private SysDeviceRepertoryMapper sysDeviceRepertoryMapper;
@Autowired
private SysIndentMapper sysIndentMapper;
@Override @Override
public List<DeviceRepertoryReq> getRepertoryList(Integer sortType, String name, String deviceType) { public List<DeviceRepertoryReq> getRepertoryList(Integer sortType, String name, String deviceType) {
...@@ -42,13 +46,25 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService { ...@@ -42,13 +46,25 @@ public class DeviceRepertoryServiceImpl implements DeviceRepertoryService {
if (!deviceRepertoryReqs.isEmpty()) { if (!deviceRepertoryReqs.isEmpty()) {
for (DeviceRepertoryReq deviceRepertoryReq : deviceRepertoryReqs) { for (DeviceRepertoryReq deviceRepertoryReq : deviceRepertoryReqs) {
Integer userId = deviceRepertoryReq.getUserId();
//在途库存 //在途库存
Integer sendDeviceNum = 0;
sendDeviceNum += sysIndentMapper.getSendDeviceNum(userId);
deviceRepertoryReq.setSendDeviceNum(sendDeviceNum);
//下属技工库存 //下属技工库存
int mechanicDeviceCount = 0;
Map<String, Object> param = new HashMap<>(16);
param.put("userId", userId);
List<MechanicRepertoryReq> mechanicRepertoryReqs = sysDeviceRepertoryMapper.getMechanicRepertoryList(param);
if(!mechanicRepertoryReqs.isEmpty()){
for(MechanicRepertoryReq mechanicRepertoryReq : mechanicRepertoryReqs){
mechanicDeviceCount+=mechanicRepertoryReq.getDeviceNum();
}
}
deviceRepertoryReq.setMechanicDeviceNum(mechanicDeviceCount);
} }
} }
return deviceRepertoryReqs; return deviceRepertoryReqs;
} }
......
...@@ -2,6 +2,9 @@ package com.glsx.ordercenter.service.impl; ...@@ -2,6 +2,9 @@ package com.glsx.ordercenter.service.impl;
import java.util.Date; import java.util.Date;
import com.glsx.ordercenter.constants.IndentStatusEnum;
import com.glsx.ordercenter.mapper.SysIndentLogisticsMapper;
import com.glsx.ordercenter.pojo.SysIndentLogistics;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -31,6 +34,9 @@ public class IndentServiceImpl implements IndentService { ...@@ -31,6 +34,9 @@ public class IndentServiceImpl implements IndentService {
@Autowired @Autowired
private ReceiveAddressService receiveAddressService; private ReceiveAddressService receiveAddressService;
@Autowired
private SysIndentLogisticsMapper sysIndentLogisticsMapper;
@Override @Override
@Transactional @Transactional
public ResultObject add(SysIndent indent) { public ResultObject add(SysIndent indent) {
...@@ -56,6 +62,36 @@ public class IndentServiceImpl implements IndentService { ...@@ -56,6 +62,36 @@ public class IndentServiceImpl implements IndentService {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} }
@Override
public Integer sendDevice(Integer userId,SysIndentLogistics sysIndentLogistics) {
//修改订单状态为待收货
SysIndent sysIndent = new SysIndent();
sysIndent.setId(sysIndentLogistics.getIndentId());
sysIndent.setIndentStatus(IndentStatusEnum.INDENT_DELIVERED.getIndentStatus());
sysIndent.setUpdateBy(userId);
sysIndent.setUpdateTime(new Date());
indentDao.updateByPrimaryKeySelective(sysIndent);
//添加到物流信息表
sysIndentLogistics.setCreateBy(userId);
sysIndentLogistics.setCreateTime(new Date());
return sysIndentLogisticsMapper.insertSelective(sysIndentLogistics);
}
@Override
public int checkDevice(Integer id,Integer userId) {
SysIndent sysIndent = new SysIndent();
sysIndent.setId(id);
sysIndent.setIndentStatus(IndentStatusEnum.INDENT_WAITDELIVER.getIndentStatus());
sysIndent.setUpdateBy(userId);
sysIndent.setUpdateTime(new Date());
return indentDao.updateByPrimaryKeySelective(sysIndent);
}
@Override
public SysIndent selectByPrimaryKey(Integer id) {
return indentDao.selectByPrimaryKey(id);
}
/** /**
* *
* @author zhanghj * @author zhanghj
......
...@@ -240,4 +240,16 @@ ...@@ -240,4 +240,16 @@
update_time = #{updateTime,jdbcType=TIMESTAMP} update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="getSendDeviceNum" resultType="java.lang.Integer">
select SUM(device_amount)
from sys_indent
WHERE indent_status=30 AND is_canceled = 0 AND
user_id in (
select
ssm.mechanic_id
from sys_service_mechanic ssm
where ssm.service_id = #{userId}
);
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -47,6 +47,17 @@ public class Constants { ...@@ -47,6 +47,17 @@ public class Constants {
public static final String SMS_REGISTER_SOURCE ="sms.register.source" ; public static final String SMS_REGISTER_SOURCE ="sms.register.source" ;
/** /**
* 发送订货单审核通过短信source
*/
public static final String SMS_CHECK_INDENT_SOURCE ="sms.check.indent.source" ;
/**
* 发送订单已发货短信source
*/
public static final String SMS_SEND_DEVICE_SOURCE ="sms.send.device.source" ;
/**
* 验证码短信source * 验证码短信source
*/ */
public static final String SMS_VERIFY_CODE_SOURCE = "sms.verify.code.source"; public static final String SMS_VERIFY_CODE_SOURCE = "sms.verify.code.source";
......
...@@ -119,6 +119,52 @@ public class CommonController { ...@@ -119,6 +119,52 @@ public class CommonController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg()); return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
} }
/**
*
* @author duanht
* @Title: sendIndentCheckPass
* @Description: TODO 发送订货单审核通过短信
* @return
* JSONObject
*
*/
@RequestMapping(value = "/sendIndentCheckPassSms", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject sendIndentCheckPassSms(@RequestParam("phone") String phone, @RequestParam("indentNo") String indentNo) throws IOException {
SmsUtil smsUtil = new SmsUtil();
try {
String msgContent = MessageFormat.format("你的订货单通过审核了,订单号:{0}",indentNo );
smsUtil.send(phone, msgContent, PropertiesUtil.getProperty(Constants.SMS_CHECK_INDENT_SOURCE));
} catch (Exception e) {
logger.error(phone + "发送订货单审核通过短信失败" + e.getMessage(), e);
return new ResultObject(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @author duanht
* @Title: sendDeviceSms
* @Description: TODO 发送订货单发货短信
* @return
* JSONObject
*
*/
@RequestMapping(value = "/sendDeviceSms", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject sendDeviceSms(@RequestParam("phone") String phone, @RequestParam("indentNo") String indentNo) throws IOException {
SmsUtil smsUtil = new SmsUtil();
try {
String msgContent = MessageFormat.format("你的订货单已经发货了,订单号:{0}",indentNo );
smsUtil.send(phone, msgContent, PropertiesUtil.getProperty(Constants.SMS_SEND_DEVICE_SOURCE));
} catch (Exception e) {
logger.error(phone + "发送已发货短信失败" + e.getMessage(), e);
return new ResultObject(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@RequestMapping(value = "/checkVerifyCode", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/checkVerifyCode", method = {RequestMethod.GET, RequestMethod.POST})
public ResultObject checkVerifyCode(@RequestParam("phone") String phone, @RequestParam("verifyCode") String verifyCode) throws IOException { public ResultObject checkVerifyCode(@RequestParam("phone") String phone, @RequestParam("verifyCode") String verifyCode) throws IOException {
String smsKey = Constants.SMS_VERIFY_CODE_PREFIX + ":" + phone; String smsKey = Constants.SMS_VERIFY_CODE_PREFIX + ":" + phone;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!