Commit 6e98baf1 by zhanghj

V1.2.0--增加PC端取消,增加短信发送功能代码

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@21983 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 5e791d49
......@@ -84,4 +84,20 @@ public interface CommonClient {
@RequestMapping(value="/carservice/publicservice/common/sendIndentSmsToService", method= RequestMethod.GET)
public JSONObject sendIndentSmsToService(@RequestParam("mechanicName")String mechanicName, @RequestParam("phone") String phone,
@RequestParam("indentNo")String indentNo);
/**
*
* @author zhanghj
* @Title: sendCancelIndentSms
* @Description: TODO 取消订货单短信通知
* @param operator
* @param phone
* @param indentNo
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/common/sendCancelIndentSms", method= RequestMethod.GET)
public JSONObject sendCancelIndentSms(@RequestParam("operator")String operator,@RequestParam("phone") String phone,
@RequestParam("indentNo")String indentNo);
}
......@@ -10,7 +10,9 @@ import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.Constants;
import com.glsx.common.utils.HttpUtils;
import com.glsx.common.utils.PropertiesUtil;
/**
*
......@@ -29,8 +31,8 @@ public class AMapUtils {
public static Integer getDistrictCodeByAddress(String address) {
Integer district = null;
//String key = PropertiesUtil.getProperty(Constants.AMAP_USER_KEY);
String key = "4d8b3b5fc398f2f79f4329b5d07732fb";
String key = PropertiesUtil.getProperty(Constants.AMAP_USER_KEY);
//String key = "4d8b3b5fc398f2f79f4329b5d07732fb";
Map<String ,String> params = new HashMap<String, String>();
params.put("address", address);
params.put("key", key);
......
......@@ -202,11 +202,11 @@ public class IndentController extends BaseController{
@AuthCheck
@RequestMapping(value = "/cancel", method = RequestMethod.POST)
public ResultObject cancel(HttpServletRequest request,Integer id) {
if (id == null) {
public ResultObject cancel(HttpServletRequest request,Integer id, Integer terminalType) {
if (id == null || terminalType == null) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
ResultObject result = indentService.cancel(request, id);
ResultObject result = indentService.cancel(request, id, terminalType);
return result;
}
......
......@@ -115,7 +115,7 @@ public interface IndentService {
* ResultObject
*
*/
ResultObject cancel(HttpServletRequest request, Integer id);
ResultObject cancel(HttpServletRequest request, Integer id, Integer terminalType);
/**
*
......
......@@ -26,6 +26,7 @@ import com.glsx.common.utils.Page;
import com.glsx.common.utils.UserUtils;
import com.glsx.ordercenter.constants.BizConstants;
import com.glsx.ordercenter.constants.IndentStatusEnum;
import com.glsx.ordercenter.constants.OrderActiveStatusEnum;
import com.glsx.ordercenter.constants.ResultCodeEnum;
import com.glsx.ordercenter.dto.Traces;
import com.glsx.ordercenter.dto.TracesVo;
......@@ -152,7 +153,7 @@ public class IndentServiceImpl implements IndentService {
logger.info("技工端增加订货单,发送短信给服务商!");
sendIndentSmsToService(mechanicName, servicePhone, indentNo);
} catch (Exception e) {
logger.info("技工端增加订货单,发送短信给服务商失败" + e);
logger.error("技工端增加订货单,发送短信给服务商失败", e);
}
}
}
......@@ -362,7 +363,7 @@ public class IndentServiceImpl implements IndentService {
@Transactional
@Override
public ResultObject cancel(HttpServletRequest request, Integer id) {
public ResultObject cancel(HttpServletRequest request, Integer id, Integer terminalType) {
// TODO Auto-generated method stub
Integer currentUserId = UserUtils.getUserId(request);
SysIndent indent = indentDao.getDetail(id);
......@@ -383,6 +384,19 @@ public class IndentServiceImpl implements IndentService {
*/
String remark = "取消订货单";
addIndentLog(id, IndentStatusEnum.INDENT_CANCEL.getIndentStatus(), remark);
/*
* PC端取消发送取消订货短信通知
*/
if (Constants.USER_TYPE_MANAGER == terminalType) {
try {
Integer userId = indent.getUserId();
String indentNo = indent.getIndentNo();
sendCancelIndentSms(request, userId, indentNo);
} catch (Exception e) {
logger.error("PC端取消发送取消订货短信通知失败", e);
}
}
} else {
throw BusinessException.create(ResultCodeEnum.FAIL.getCode(), ResultCodeEnum.FAIL.getMsg());
}
......@@ -390,6 +404,18 @@ public class IndentServiceImpl implements IndentService {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
private void sendCancelIndentSms(HttpServletRequest request, Integer userId, String indentNo) {
// TODO Auto-generated method stub
String operator = UserUtils.getUserName(request);
JSONObject json = userClient.getUserById(userId);
if (json != null && json.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
JSONObject object = json.getJSONObject("data");
String phone = object.getString("phoneNumber");
logger.info("PC端取消订货短信通知");
commonClient.sendCancelIndentSms(operator, phone, indentNo);
}
}
@Override
public List<SysIndent> getIndentListByTerminalType(HttpServletRequest request, Page page,
SysIndent indent) {
......
......@@ -18,9 +18,14 @@ public class Constants {
/**
* 技工发起订货单,请求服务商审核短信模板
*/
public static final String SEND_INDENT_TO_SERVICE_SMS_CONTENT = "{0}订货了,请快点审核吧!订单号:{1}";
public static final String SEND_INDENT_TO_SERVICE_SMS_CONTENT = "{0}订货了,请快点审核吧!订单号:{1}。";
/**
* 取消订货单,短信模板
*/
public static final String CANCEL_INDENT_SMS_CONTENT = "你的订货单被{0}取消,订单号:{1}。";
/**
* 短信类型
*/
/**
......@@ -63,6 +68,10 @@ public class Constants {
* 技工给服务商发送订货单短信source
*/
public static final String SMS_SEND_INDENT_SOURCE = "sms.send.indnet.source";
/**
* 取消订货单短信source
*/
public static final String SMS_CANCEL_INDENT_SOURCE = "sms.cancel.indnet.source";
/**
* 验证码短信source
......
......@@ -200,4 +200,21 @@ public class CommonController {
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
* 取消订货单发送短信
*/
@RequestMapping(value = "/sendCancelIndentSms", method = {RequestMethod.GET})
public ResultObject sendCancelIndentSms(@RequestParam("operator")String operator, @RequestParam("phone") String phone,
@RequestParam("indentNo")String indentNo) throws IOException {
SmsUtil smsUtil = new SmsUtil();
try {
String msgContent = MessageFormat.format(Constants.CANCEL_INDENT_SMS_CONTENT, operator, indentNo );
smsUtil.send(phone, msgContent, PropertiesUtil.getProperty(Constants.SMS_CANCEL_INDENT_SOURCE));
} catch (Exception e) {
logger.error(phone + "发送取消订货短信失败" + e.getMessage(), e);
return new ResultObject(ResultCodeEnum.SMS_SEND_FAIL.getCode(), ResultCodeEnum.SMS_SEND_FAIL.getMsg());
}
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
}
......@@ -1142,13 +1142,18 @@ public class UserController extends BaseController {
*/
@RequestMapping(value = "/getAllIndentUserList", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody
public ResultObject getAllIndentUserList(@RequestParam(defaultValue = "1") int pageIndex, @RequestParam(defaultValue = "10") int pageSize, String queryContent) {
public ResultObject getAllIndentUserList(Integer pageIndex, Integer pageSize, String queryContent) {
Map<String, Object> result = new HashMap<String, Object>(16);
Page page = new Page(pageIndex, pageSize);
Page page = null;
if (pageIndex != null && pageSize != null) {
page = new Page(pageIndex, pageSize);
}
List<SysManager> list = sysUserService.getAllIndentUserList(queryContent, page);
com.github.pagehelper.Page<SysManager> pages = (com.github.pagehelper.Page<SysManager>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
if (page != null) {
com.github.pagehelper.Page<SysManager> pages = (com.github.pagehelper.Page<SysManager>) list;
page.setTotalCount((int) pages.getTotal());
result.put("page", page);
}
result.put("items", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
}
......
......@@ -902,7 +902,9 @@ public class SysUserServiceImpl implements SysUserService {
@Override
public List<SysManager> getAllIndentUserList(String queryContent, Page page) {
// TODO Auto-generated method stub
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
if (page != null) {
PageHelper.startPage(page.getPageIndex(), page.getPageSize(), true);
}
return sysUserMapper.getAllIndentUserList(queryContent);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!