|
@@ -0,0 +1,1551 @@
|
|
|
+package cn.haliaeetus.controller.appdevapi;
|
|
|
+
|
|
|
+
|
|
|
+import cn.haliaeetus.constants.Constants;
|
|
|
+import cn.haliaeetus.controller.web.enums.SMSErrorCodeEnum;
|
|
|
+import cn.haliaeetus.controller.web.enums.StatusCodeEnum;
|
|
|
+import cn.haliaeetus.controller.web.querycondition.DeliveryQueryCondition;
|
|
|
+import cn.haliaeetus.dao.UserDao;
|
|
|
+import cn.haliaeetus.entity.*;
|
|
|
+import cn.haliaeetus.entity.dto.DeliveryDto;
|
|
|
+import cn.haliaeetus.entity.dto.QueryPageDto;
|
|
|
+import cn.haliaeetus.entity.dto.QueryPageSubDto;
|
|
|
+import cn.haliaeetus.entity.esdto.ESDeliveryQueryCondition;
|
|
|
+import cn.haliaeetus.entity.jspo.JDeliveryDto;
|
|
|
+import cn.haliaeetus.entity.jspo.JsonMsg;
|
|
|
+import cn.haliaeetus.framework.base.controller.BaseController;
|
|
|
+import cn.haliaeetus.framework.toolkit.PagedList;
|
|
|
+import cn.haliaeetus.framework.util.DateUtil;
|
|
|
+import cn.haliaeetus.framework.util.HttpUtil;
|
|
|
+import cn.haliaeetus.service.*;
|
|
|
+import cn.haliaeetus.service.rsync.ConsumeRecordService;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+import static cn.haliaeetus.framework._.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查询 发送短信
|
|
|
+ * Created by Administrator on 2018/12/12 0012.
|
|
|
+ * APP首页查询类
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+public class AppQueryAction extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private BasicInfoService basicInfoService;
|
|
|
+ @Autowired
|
|
|
+ private StoreStaffService storeStaffService;
|
|
|
+ @Autowired
|
|
|
+ private StatService statService;
|
|
|
+ @Autowired
|
|
|
+ private DeliveryService deliveryService;
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+ @Autowired
|
|
|
+ private DeliveryScanBatchService scanBatchService;
|
|
|
+ @Autowired
|
|
|
+ private TypeLibraryService typeLibraryService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SmsRecordService smsRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ConsumeRecordService consumeRecordService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WhiteListService whiteListService;
|
|
|
+
|
|
|
+ private static List<ExpressType> expressList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = {"/app/api/v1/appquery"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object appQuery(HttpServletRequest request) throws Exception,
|
|
|
+ ParseException {
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ /*String md5Pwd = Md5Util.md5AsLowerHex(password);
|
|
|
+ User user = userService.getUserByIdAndPwd(userId, md5Pwd);*/
|
|
|
+ //根据时间和用户id查询这天的数据
|
|
|
+ if (null == user) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+ Store store = basicInfoService.getStoreById(storeId);
|
|
|
+ /*List<Integer> deliveryExpList = formatIds(store.getDispatchIds(), ",");
|
|
|
+ for(Integer a:deliveryExpList){
|
|
|
+ List<ExpressType> tmp=getRemoteExpressList(a);
|
|
|
+ if(tmp!=null){
|
|
|
+ expressList.add(tmp.get(0));
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ List<ExpressType> expressList = basicInfoService.getAllExpressList();
|
|
|
+ //获取首页当日实时统计
|
|
|
+ JsonObject data = new JsonObject();
|
|
|
+ data.addProperty("today_instore", getTodayIn(storeId)); // 今日入库
|
|
|
+ data.addProperty("all_instore", getSignStatusCount(storeId)); // 未签收
|
|
|
+ data.addProperty("smsBalance", user.getSmsBalance());//余额*/
|
|
|
+ /*data.addProperty("today_instore", 5); // 今日入库
|
|
|
+ data.addProperty("all_instore", 3); // 未签收
|
|
|
+ data.addProperty("smsBalance",255);//余额*/
|
|
|
+ String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String time1 = beginTime1.trim() + " 00:00:00";
|
|
|
+ String time2 = endTime1.trim() + " 23:59:59";
|
|
|
+
|
|
|
+ //TODO add2019-04-04 today_todo
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ qc.setExpId(0);
|
|
|
+ qc.setShelfId(0);
|
|
|
+ qc.setCreateTime(time1, time2);
|
|
|
+ ArrayList<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ String subSql = " and userPhone = '' ";
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ qc.setP(1);
|
|
|
+ qc.setBegin(0);
|
|
|
+ qc.setPageSize(10000);
|
|
|
+ QueryPageDto pageDto = deliveryService.getQueryPageDto(qc, expressList);
|
|
|
+ PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
|
|
|
+ if (deliveryPagedList != null && deliveryPagedList.getItems() != null) {
|
|
|
+ data.addProperty("today_todo", deliveryPagedList.getItems().size());
|
|
|
+ } else {
|
|
|
+ data.addProperty("today_todo", 0);
|
|
|
+ }
|
|
|
+ //未通知 短信未发送
|
|
|
+ Integer notice = this.getNotSendAmount(storeId, expressList, time1, time2, -1);
|
|
|
+ data.addProperty("notice", notice);
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
+ jsonObject.addProperty("code", 0);
|
|
|
+ jsonObject.addProperty("msg", "");
|
|
|
+ jsonObject.add("data", data);
|
|
|
+ return jsonObject.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = {"/app/api/v1/querytest"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object query() {
|
|
|
+ Map reqMap = new HashMap();
|
|
|
+ reqMap.put("_haliaeetus_userId_", "15355426462");
|
|
|
+ reqMap.put("_haliaeetus_web_", "f9445af5eb6e86353cc2a7cf0b621126");
|
|
|
+ reqMap.put("p", "1");
|
|
|
+ reqMap.put("pageSize", "20");
|
|
|
+ reqMap.put("beginTime", "2019-06-04");
|
|
|
+ reqMap.put("endTime", "2019-06-04");
|
|
|
+ reqMap.put("type", "ALL");
|
|
|
+ reqMap.put("smsStatus", "0");
|
|
|
+ reqMap.put("queryType", "1");
|
|
|
+ reqMap.put("pageType", "1");
|
|
|
+ String url = "http://87.fengzhan100.com/app/api/v1/query";
|
|
|
+ String res = HttpUtil.post(url, reqMap);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回参数 快递 是否签收 用户手机号 面单号 取货码 入库时间 签收时间 是否通知 未通知 成功数 失败数 通知数
|
|
|
+ //首页搜索查询
|
|
|
+ @Autowired
|
|
|
+ private AccessLimitService accessLimitService;
|
|
|
+
|
|
|
+ @RequestMapping(value = {"/app/api/v1/query/old"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object query(HttpServletRequest request,
|
|
|
+ @RequestParam(defaultValue = "1") String p,//第几页
|
|
|
+ @RequestParam(defaultValue = "20") String pageSize,//每页多少
|
|
|
+ @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
|
|
|
+ @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
|
|
|
+ @RequestParam(defaultValue = "ALL") String type,//All全部 未入库,已到库,已出库
|
|
|
+ @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
|
|
|
+ @RequestParam(defaultValue = "0") String shelfId,//
|
|
|
+ @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
|
|
|
+ @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
|
|
|
+ @RequestParam(defaultValue = "") String expcode,
|
|
|
+ @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
|
|
|
+ @RequestParam(defaultValue = "-1") String search,
|
|
|
+ @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
|
|
|
+ @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
|
|
|
+ @RequestParam(defaultValue = "-1") String sort) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+
|
|
|
+ if (!accessLimitService.tryAcquire()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+// Map reqMap = new HashMap();
|
|
|
+ String userId = request.getParameter(COOKIE_USERID);
|
|
|
+ StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
|
|
|
+ if (storeReqLimit.getIsLimitFlag()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+// String password = request.getParameter(COOKIE_KEY);
|
|
|
+// reqMap.put("_haliaeetus_userId_",userId);
|
|
|
+// reqMap.put("_haliaeetus_web_",password);
|
|
|
+// reqMap.put("p",p);
|
|
|
+// reqMap.put("pageSize",pageSize);
|
|
|
+// reqMap.put("beginTime",beginTime);
|
|
|
+// reqMap.put("endTime",endTime);
|
|
|
+// reqMap.put("type",type);
|
|
|
+// reqMap.put("expId",expId);
|
|
|
+// reqMap.put("shelfId",shelfId);
|
|
|
+// reqMap.put("smsType",smsType);
|
|
|
+// reqMap.put("smsStatus",smsStatus);
|
|
|
+// reqMap.put("expcode",expcode);
|
|
|
+// reqMap.put("queryType",queryType);
|
|
|
+// reqMap.put("search",search);
|
|
|
+// reqMap.put("pageType",pageType);
|
|
|
+// reqMap.put("sort",sort);
|
|
|
+// String searchPhoenixTestIP=basicInfoService.getConfigurationByCode("searchPhoenixTestIP").getOValue1();
|
|
|
+// String url1 = "http://"+searchPhoenixTestIP+"/app/api/v1/query";
|
|
|
+// String res = HttpUtil.post(url1,reqMap);
|
|
|
+// return res;
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ if (user == null) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ int p1 = Integer.parseInt(p);
|
|
|
+ p1 = max(1, p1);
|
|
|
+ int begin = (p1 - 1) * Integer.parseInt(pageSize);
|
|
|
+
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ //分页不是默认值就设值
|
|
|
+ if (Integer.parseInt(pageSize) != 20) {
|
|
|
+ qc.setPageSize(Integer.parseInt(pageSize));
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ /*if(!smsStatus.equals("3")){*/
|
|
|
+ Date date = new Date();
|
|
|
+ if (null == beginTime || "".equals(beginTime)) {
|
|
|
+ beginTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ if (null == endTime || "".equals(endTime)) {
|
|
|
+ endTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ /*}*/
|
|
|
+
|
|
|
+ //判断今天、近一月
|
|
|
+ String time1 = "";
|
|
|
+ if (!beginTime.equals("")) {
|
|
|
+ time1 = beginTime.trim() + " 00:00:00";
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(time1));
|
|
|
+ }
|
|
|
+ String time2 = "";
|
|
|
+ if (!endTime.equals("")) {
|
|
|
+ time2 = endTime.trim() + " 23:59:59";
|
|
|
+ qc.setEndTime(Timestamp.valueOf(time2));
|
|
|
+ }
|
|
|
+ endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
|
|
|
+ // 封装查询条件
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ qc.setP(p1);
|
|
|
+ qc.setBegin(begin);
|
|
|
+ if (smsType.equals("短信") || smsType.equals("1")) {
|
|
|
+ qc.setSmsType(1);
|
|
|
+ } else if (smsType.equals("微信") || smsType.equals("2")) {
|
|
|
+ qc.setSmsType(2);
|
|
|
+ } else {
|
|
|
+ qc.setSmsType(0);//0为查询全部
|
|
|
+ }
|
|
|
+ qc.setSmsStatus(Integer.valueOf(smsStatus));//通知状态
|
|
|
+ //状态和类型没处理
|
|
|
+ switch (type) {
|
|
|
+ case "ALL": // 全部
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ break;
|
|
|
+ case "NOSTORE": // 未到貨
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ // qc.setShelfId(0);
|
|
|
+ break;
|
|
|
+ case "WAITINSTORE": // 待入庫
|
|
|
+ //statusList.add(Constants.ORDER_STATUS_WAIT_IN_STORE);
|
|
|
+ //qc.setStatusStr(statusList);
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ break;
|
|
|
+ case "INSTORE": // 已入库
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "OUTSTORE": // 已出库
|
|
|
+ statusList.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "ALLDISPATCH":// 所有派送中
|
|
|
+ statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_DISPATCHING);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "DISPATCH": // 派送中
|
|
|
+ statusList.add(Constants.ORDER_STATUS_DISPATCHING);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "MKDISPATCH": // 麦客配送中
|
|
|
+ statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "LEAVESTORE": // 离库
|
|
|
+ statusList.add(Constants.ORDER_STATUS_LEAVE_STORE);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_LEAVE_STORE);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ break;
|
|
|
+ case "ALLINSTORE": // 总在库
|
|
|
+ String todayt = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String tomorrowt = DateUtil.addDay(todayt, "yyyy-MM-dd", 1);
|
|
|
+// String before10dayst = DateUtil.addDay(todayt, "yyyy-MM-dd", -10);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+// qc.setCreateTime(before10dayst, tomorrowt);
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ qc.setBeginTime(sdf.parse(beginTime));
|
|
|
+ qc.setEndTime(sdf.parse(endTime));
|
|
|
+ break;
|
|
|
+ case "WHITELIST":// 白名单
|
|
|
+ qc.setIswhite(1);
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ break;
|
|
|
+ case "INDEX":
|
|
|
+ beginTime = DateUtil.addMonth(beginTime, "yyyy-MM-dd", -1);
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!"ALLINSTORE".equals(type) && !"ALLDISPATCH".equals(type)
|
|
|
+ && !"ALL".equals(type) && !"INDEX".equals(type)
|
|
|
+ && !"WHITELIST".equals(type) && !"NOSTORE".equals(type)) {
|
|
|
+ qc.setStatusTime(beginTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ String subSql = "";
|
|
|
+ if (!"WHITELIST".equals(type)) {
|
|
|
+ subSql = getSubSql(expcode, Integer.valueOf(queryType));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!subSql.equals("")) {
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据店铺id查询当前店铺的白名单客户
|
|
|
+ List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
|
|
|
+ Map map = new HashMap();
|
|
|
+ for (WhiteList white : list) {
|
|
|
+ map.put(white.getUsermobile(), white);
|
|
|
+ }
|
|
|
+
|
|
|
+ qc.setExpId(Integer.valueOf(expId));
|
|
|
+ qc.setShelfId(Integer.valueOf(shelfId));
|
|
|
+
|
|
|
+ QueryPageDto pageDto = null;
|
|
|
+ QueryPageSubDto pageSubDto = null;
|
|
|
+ JsonMsg jsonMsg = JsonMsg.getSuccess();
|
|
|
+ if (Integer.valueOf(smsStatus) != -2) {
|
|
|
+ qc.setSmsStatus(Integer.valueOf(smsStatus));
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ subSql = getSubSql(expcode, Integer.valueOf(queryType));
|
|
|
+// if (!subSql.equals("")) {
|
|
|
+// qc.setSubSql(subSql);
|
|
|
+// }
|
|
|
+ //subSql += " and userPhone > '' and odeliveryType<>'PS' ";
|
|
|
+ if (null == search || search.equals("-1") || "".equals(search)) {
|
|
|
+ subSql += " and userPhone > '' ";
|
|
|
+ }
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+
|
|
|
+
|
|
|
+ qc.setPageSize(Integer.parseInt(pageSize));
|
|
|
+ List<Integer> statusList1 = new ArrayList<Integer>();
|
|
|
+ if ("1".equals(pageType)) {
|
|
|
+ //只查在库单子
|
|
|
+ statusList1.add(122);
|
|
|
+ //滞留
|
|
|
+ statusList1.add(124);
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_LEAVE_STORE);
|
|
|
+ } else if (!"3".equals(smsStatus)) {
|
|
|
+ //只查在库单子
|
|
|
+ statusList1.add(122);
|
|
|
+ //滞留
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ } else {
|
|
|
+ //只查在库单子
|
|
|
+ statusList1.add(122);
|
|
|
+ //滞留
|
|
|
+ statusList1.add(124);
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ }
|
|
|
+ //只查在库单子
|
|
|
+// statusList1.add(122);
|
|
|
+ //statusList.add(126);
|
|
|
+// statusList1.add(124);
|
|
|
+ //滞留
|
|
|
+// statusList1.add(Constants.ORDER_STATUS_REJECT_RETENTION );
|
|
|
+ //已完成的
|
|
|
+ if (null != search && search.equals("0")) {
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ statusList1.add(Constants.ORDER_STATUS_LEAVE_STORE);
|
|
|
+ }
|
|
|
+ qc.setStatusStr(statusList1);
|
|
|
+ pageSubDto = deliveryService.appGetSmsFail4Page(qc);
|
|
|
+ pageDtos(pageSubDto);
|
|
|
+ jsonMsg.add("list", getJDeliveryDto(pageSubDto.getPageList(), map, pageType));
|
|
|
+ jsonMsg.add("curPage", pageSubDto.getPageList().getCurPage());
|
|
|
+ jsonMsg.add("totalPages", pageSubDto.getPageList().getTotalPages());
|
|
|
+ //总条数
|
|
|
+ jsonMsg.add("totalCount", pageSubDto.getPageList().getTotal());
|
|
|
+ int noTice = pageSubDto.getNoTice();
|
|
|
+ int scuessTice = pageSubDto.getScuessTice();
|
|
|
+ int fileTice = pageSubDto.getFileTice();
|
|
|
+ jsonMsg.add("noTice", noTice);
|
|
|
+// jsonMsg.add("noTice",getJDeliveryDto(pageSubDto.getPageList(),map).size());
|
|
|
+ jsonMsg.add("scuessTice", scuessTice);
|
|
|
+ jsonMsg.add("fileTice", fileTice);
|
|
|
+ jsonMsg.add("sendTice", scuessTice + fileTice);//已发送
|
|
|
+ } else {
|
|
|
+ if ("NOSTORE".equals(type)) {
|
|
|
+ // 未到货逻辑
|
|
|
+ subSql = getNoArriveSubSql(expcode, Integer.valueOf(queryType));
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ pageDto = deliveryService.getNoArrive4Page(qc);
|
|
|
+ jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
|
|
|
+ jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
|
|
|
+ jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
|
|
|
+ //总条数
|
|
|
+ jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
|
|
|
+ //jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
|
|
|
+ // request.setAttribute("pages", pageDto.getPageList());
|
|
|
+ } else if ("WAITINSTORE".equals(type)) {
|
|
|
+ // 待入库,下车扫描
|
|
|
+ subSql = getNoArriveSubSql(expcode, Integer.valueOf(queryType));
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ pageDto = deliveryService.getWaitInStore4Page(qc);
|
|
|
+ jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
|
|
|
+ jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
|
|
|
+ jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
|
|
|
+ //总条数
|
|
|
+ jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
|
|
|
+ //jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
|
|
|
+ //request.setAttribute("pages", pageDto.getPageList());
|
|
|
+ } else {
|
|
|
+
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ switch (Integer.valueOf(sort)) {
|
|
|
+ case 0:
|
|
|
+ qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
|
|
|
+ qc.setOrder("asc");
|
|
|
+ // sqlEnd = " order by (d.shelfCode+0)";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ // sqlEnd = " order by (d.shelfCode+0) desc";
|
|
|
+ qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ pageDto = deliveryService.getQueryPageDto(qc);
|
|
|
+ pageDtos(pageDto);
|
|
|
+ jsonMsg.add("list", getJDeliveryDto(pageDto.getPageList(), map, pageType));
|
|
|
+ jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
|
|
|
+ jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
|
|
|
+ //总条数
|
|
|
+ jsonMsg.add("totalCount", pageDto.getPageList().getTotal());
|
|
|
+ // jdto.setjDeliveryDto(getJDeliveryDto(pageDto.getPageList()));
|
|
|
+ // request.setAttribute("pages", pageDto.getPageList());
|
|
|
+ }
|
|
|
+ jsonMsg.add("noTice", 0);
|
|
|
+ jsonMsg.add("scuessTice", 0);
|
|
|
+ jsonMsg.add("fileTice", 0);
|
|
|
+ jsonMsg.add("sendTice", 0);//已发送*/
|
|
|
+ }
|
|
|
+ jsonMsg.add("requestSign", requestSign);
|
|
|
+ log.info("bs2.sql.delivery.query.time:"
|
|
|
+ + (int) (System.currentTimeMillis() - now));
|
|
|
+ log.info("bs2.sql.delivery.query.storeid:" + storeId);
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据查询条件发送短信
|
|
|
+ */
|
|
|
+ @RequestMapping(value = {"/app/api/v1/querySmsSend"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object querySmsSend(HttpServletRequest request,
|
|
|
+ @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
|
|
|
+ @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
|
|
|
+ @RequestParam(defaultValue = "1") String smsType,//通知类型短信或者微信
|
|
|
+ @RequestParam(defaultValue = "-1") String smsStatus,//通知状态
|
|
|
+ @RequestParam(defaultValue = "") String expcode,
|
|
|
+ @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
|
|
|
+ @RequestParam(defaultValue = "-1") String sort) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ if (user == null) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+ if (null == beginTime || "".equals(beginTime)) {
|
|
|
+ beginTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ if (null == endTime || "".equals(endTime)) {
|
|
|
+ endTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ //判断今天、近一月
|
|
|
+ String time1 = "";
|
|
|
+ if (!beginTime.equals("")) {
|
|
|
+ time1 = beginTime.trim() + " 00:00:00";
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(time1));
|
|
|
+ }
|
|
|
+ String time2 = "";
|
|
|
+ if (!endTime.equals("")) {
|
|
|
+ time2 = endTime.trim() + " 23:59:59";
|
|
|
+ qc.setEndTime(Timestamp.valueOf(time2));
|
|
|
+ }
|
|
|
+ endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
|
|
|
+ // 封装查询条件
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+
|
|
|
+// qc.setSmsType(Integer.valueOf(smsType));//通知类型
|
|
|
+ qc.setSmsStatus(Integer.valueOf(smsStatus));//通知状态
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+
|
|
|
+ //状态和类型没处理
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ if (null == smsStatus || "".equals(smsStatus)) {
|
|
|
+ qc.setSmsStatus(-1);
|
|
|
+ }
|
|
|
+ qc.setSmsStatus(Integer.valueOf(smsStatus));
|
|
|
+ //qc.setSignStatus("0");
|
|
|
+ String subSql = " and userPhone > '' and odeliveryType<>'PS' ";
|
|
|
+ /* if(null != queryType){
|
|
|
+ String querySubSql = getSubSql(expcode,Integer.parseInt(queryType));
|
|
|
+ if(!"".equals(querySubSql)){
|
|
|
+ subSql += querySubSql;
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ String result = deliveryService.appGetSendSmsdeliveryIds(qc);
|
|
|
+ if (null == result || "".equals(result)) {
|
|
|
+ return buildJson(-1, "没有可发送短信单号");
|
|
|
+ }
|
|
|
+ String[] ids = result.split(",");
|
|
|
+ //发送短信
|
|
|
+ if ((user.getIsSmsFree() == null || user.getIsSmsFree() == Constants.NO)) {
|
|
|
+ int size = ids.length;
|
|
|
+ BigDecimal consume = calConsume(user.getSmsPrice(), size);
|
|
|
+ if ((user.getSmsBalance() == null || user.getSmsBalance().compareTo(consume) <= 0)) {
|
|
|
+ return buildJson(66, "余额不足,请先充值");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ /*deliveryService.resendAllSmsBatch(user, ids);*/
|
|
|
+ deliveryService.resendAllSms4app(user, ids);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return buildJson(-1, "发送失败");
|
|
|
+ }
|
|
|
+ JsonMsg jsonMsg = JsonMsg.getSuccess();
|
|
|
+ jsonMsg.setMsg("发送成功");
|
|
|
+ jsonMsg.add("result", result);
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal calConsume(BigDecimal smsPrice, int smsCount) {
|
|
|
+ if (smsPrice == null) {
|
|
|
+ return BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ return smsPrice.multiply(new BigDecimal(smsCount));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 完善散单
|
|
|
+ */
|
|
|
+ @RequestMapping("/app/api/v1/complete")
|
|
|
+ @ResponseBody
|
|
|
+ public Object appComplete(HttpServletRequest request,
|
|
|
+ @RequestParam(defaultValue = "1") String p,
|
|
|
+ @RequestParam(defaultValue = "20") String pageSize,
|
|
|
+ @RequestParam(defaultValue = "") String beginTime,
|
|
|
+ @RequestParam(defaultValue = "") String endTime,
|
|
|
+ @RequestParam(defaultValue = "UNCOMPLETE") String type,
|
|
|
+ @RequestParam(defaultValue = "0") int expId,
|
|
|
+ @RequestParam(defaultValue = "0") int shelfId,
|
|
|
+ @RequestParam(defaultValue = "") String expcode,
|
|
|
+ @RequestParam(defaultValue = "1") int queryType,
|
|
|
+ @RequestParam(defaultValue = "ALL") String odeliverytype,
|
|
|
+ @RequestParam(defaultValue = "-1") int offset,
|
|
|
+ @RequestParam(defaultValue = "-1") int sort) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+ int p2 = max(1, Integer.parseInt(p));
|
|
|
+ int begin = (p2 - 1) * Integer.parseInt(pageSize);
|
|
|
+
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ //判断今天、近一月
|
|
|
+ if (!beginTime.equals("")) {
|
|
|
+ String time = beginTime.trim() + " 00:00:00";
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(time));
|
|
|
+ }
|
|
|
+ if (!endTime.equals("")) {
|
|
|
+ String time = endTime.trim() + " 23:59:59";
|
|
|
+ qc.setEndTime(Timestamp.valueOf(time));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (offset == -1) {
|
|
|
+ if (isEmpty(beginTime))
|
|
|
+ beginTime = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ if (isEmpty(endTime))
|
|
|
+ endTime = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+
|
|
|
+ endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
|
|
|
+ } else {
|
|
|
+ String today = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -offset);
|
|
|
+ endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 封装查询条件
|
|
|
+
|
|
|
+ qc.setP(Integer.parseInt(p));
|
|
|
+ qc.setBegin(begin);
|
|
|
+
|
|
|
+ String subSql = getSubSql(expcode, queryType);
|
|
|
+
|
|
|
+ //queryTye = 2表示根据手机号模糊查询,以下逻辑可优化
|
|
|
+ if (!"ALL".equals(type)) {
|
|
|
+ switch (type) {
|
|
|
+ case "UNCOMPLETE": // 未完善
|
|
|
+ subSql += " and userPhone = '' ";
|
|
|
+ break;
|
|
|
+ case "COMPLETED": // 已完善
|
|
|
+ subSql += " and userPhone > '' ";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!subSql.equals("")) {
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"ALL".equals(odeliverytype)) {
|
|
|
+ if ("PS".equals(odeliverytype)) {
|
|
|
+ qc.setOdeliveryType(odeliverytype);
|
|
|
+ } else {
|
|
|
+ qc.setOdeliveryType("ZI','P2P");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ qc.setExpId(expId);
|
|
|
+ qc.setShelfId(shelfId);
|
|
|
+
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+
|
|
|
+ ArrayList<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+// statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ switch (sort) {
|
|
|
+ case 0:
|
|
|
+ qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
|
|
|
+ qc.setOrder("asc");
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ qc.setOrderField("cast(IFNULL(shelfCode,0) as UNSIGNED INTEGER)");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryPageDto pageDto = deliveryService.getQueryPageDto(qc);
|
|
|
+
|
|
|
+
|
|
|
+ for (DeliveryDto d : pageDto.getPageList().getItems()) {
|
|
|
+ List<DeliveryScanBatch> deliveryScanBatches = scanBatchService.getByCondition(d.getDelivery().getStoreId(), d.getDelivery().getExpcode(), d.getDelivery().getExpId(), null, null, null);
|
|
|
+ if (d.getDelivery().getUserPhone() != null) {
|
|
|
+ if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
|
|
|
+ StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(d.getDelivery().getUserPhone()) || org.apache.commons.lang.StringUtils.isBlank(d.getDelivery().getUserPhone())) {
|
|
|
+ number.append("");
|
|
|
+ } else {
|
|
|
+ number.replace(3, 10, "*******");
|
|
|
+ }//number.replace(3, 10, "*******");
|
|
|
+ d.getDelivery().setUserPhone(number.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
|
|
|
+ //货架
|
|
|
+ List<StoreShelf> storeShelfs = pageDto.getStoreShelfs();
|
|
|
+
|
|
|
+ //根据店铺id查询当前店铺的白名单客户
|
|
|
+ List<WhiteList> list = whiteListService.getByStoreId(user.getStoreId());
|
|
|
+ Map map = new HashMap();
|
|
|
+ for (WhiteList white : list) {
|
|
|
+ map.put(white.getUsermobile(), white);
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonMsg jsonMsg = JsonMsg.getSuccess();
|
|
|
+ jsonMsg.add("list", getJDeliveryDto(deliveryPagedList, map, "-1"));
|
|
|
+ jsonMsg.add("shelfList", storeShelfs);
|
|
|
+ jsonMsg.add("curPage", pageDto.getPageList().getCurPage());
|
|
|
+ jsonMsg.add("totalPages", pageDto.getPageList().getTotalPages());
|
|
|
+
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询单条
|
|
|
+ */
|
|
|
+ @RequestMapping("/app/api/v1/queryOne")
|
|
|
+ @ResponseBody
|
|
|
+ public Object appQueryOne(HttpServletRequest request,
|
|
|
+ @RequestParam(defaultValue = "") String deliveryId) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ if (null == user) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+ if (null == deliveryId || "".equals(deliveryId)) {
|
|
|
+ return buildJson(-1, "快件id错误");
|
|
|
+ }
|
|
|
+ DeliveryDto deliveryDto = deliveryService.getByIdDeliveryDto(user.getStoreId(), Integer.parseInt(deliveryId));
|
|
|
+ if (null == deliveryDto) {
|
|
|
+ return buildJson(-1, "快件不存在");
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ JDeliveryDto jdo = new JDeliveryDto();
|
|
|
+ Delivery delivery = deliveryDto.getDelivery();
|
|
|
+ List<ExpressType> expressTypes = basicInfoService.getAllExpressMapMemcached();
|
|
|
+ for (ExpressType expressType : expressTypes) {
|
|
|
+ if (expressType.getId().intValue() == delivery.getExpId().intValue()) {
|
|
|
+ jdo.setExpId(expressType.getExpId());
|
|
|
+ jdo.setExpName(expressType.getExpName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != delivery.getCreateTime() && !"".equals(delivery.getCreateTime())) {
|
|
|
+ jdo.setCreateTime(sdf.format(delivery.getCreateTime()));
|
|
|
+ }
|
|
|
+ jdo.setId(delivery.getId());
|
|
|
+ jdo.setExpcode(delivery.getExpcode());
|
|
|
+ jdo.setShelfCode(delivery.getShelfCode());
|
|
|
+ if (null != delivery.getSignDtm() && !"".equals(delivery.getSignDtm())) {
|
|
|
+ jdo.setSignDtm(sdf.format(delivery.getSignDtm()));
|
|
|
+ }
|
|
|
+ jdo.setStatus(delivery.getStatus());
|
|
|
+ jdo.setUserPhone(delivery.getUserPhone());
|
|
|
+ jdo.setSmsStatus(deliveryDto.getSmsStatus());
|
|
|
+ jdo.setShelfId(delivery.getShelfId());
|
|
|
+ jdo.setDeliveryUid(delivery.getDeliveryUid());
|
|
|
+ jdo.setDeliveryUname(delivery.getDeliveryUname());
|
|
|
+ if (null != delivery.getUploadDtm() && !"".equals(delivery.getUploadDtm())) {
|
|
|
+ jdo.setUploadDtm(sdf.format(delivery.getUploadDtm()));
|
|
|
+ }
|
|
|
+ JsonMsg jsonMsg = JsonMsg.getSuccess();
|
|
|
+ jsonMsg.add("deliveryInfo", jdo);
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Integer> formatIds(String ids, String separator) {
|
|
|
+ List<Integer> idList = new ArrayList<Integer>();
|
|
|
+
|
|
|
+ String[] idStringArray = StringUtils.split(ids, separator);
|
|
|
+ for (String idString : idStringArray) {
|
|
|
+ idList.add(Integer.parseInt(idString));
|
|
|
+ }
|
|
|
+
|
|
|
+ return idList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getTodayIn(int storeId) throws Exception {
|
|
|
+ String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String time1 = beginTime1.trim() + " 00:00:00";
|
|
|
+ String time2 = endTime1.trim() + " 23:59:59";
|
|
|
+ endTime1 = DateUtil.addDay(endTime1, "yyyy-MM-dd", 1);
|
|
|
+ DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ qc.setBeginTime(formatter.parse(time1));
|
|
|
+ qc.setEndTime(formatter.parse(time2));
|
|
|
+ qc.setExpId(0);
|
|
|
+ qc.setShelfId(0);
|
|
|
+ qc.setCreateTime(beginTime1, endTime1);
|
|
|
+ ArrayList<Integer> statusList = new ArrayList<>();
|
|
|
+ /*statusList.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ qc.setStatusStr(statusList);*/
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ /*String subSql = " and userPhone = '' ";
|
|
|
+ qc.setSubSql(subSql);*/
|
|
|
+ qc.setP(1);
|
|
|
+ qc.setBegin(0);
|
|
|
+ qc.setPageSize(20);
|
|
|
+ /* QueryPageDto pageDto = deliveryService.getQueryPageDto(qc,expressList);
|
|
|
+ PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
|
|
|
+ if(deliveryPagedList!=null){
|
|
|
+ return Integer.parseInt(String.valueOf(pageDto.getPageList().getTotal()));
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }*/
|
|
|
+ return (int) deliveryService.getCount(qc);
|
|
|
+ }
|
|
|
+
|
|
|
+ private DeliveryQueryCondition getDeliveryQueryCondition(int storeId) {
|
|
|
+
|
|
|
+ DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
|
|
|
+ qc.setPageSize(20);
|
|
|
+ return qc;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取自提在库
|
|
|
+ public int getAllInstore(int storeId) throws Exception {
|
|
|
+ int p = 1;
|
|
|
+ int pageSize = 20;
|
|
|
+ String type = "ALLINSTORE";
|
|
|
+ int expId = 0;
|
|
|
+ int shelfId = 0;
|
|
|
+ String expcode = "";
|
|
|
+ int queryType = 2;
|
|
|
+ int offset = -1;
|
|
|
+ int sort = -1;
|
|
|
+
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Calendar cale = Calendar.getInstance();
|
|
|
+ cale.add(Calendar.MONTH, 0);
|
|
|
+ cale.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+ String beginTime = format.format(new Date());
|
|
|
+ String endTime = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ p = max(1, p);
|
|
|
+ int begin = (p - 1) * pageSize;
|
|
|
+
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ //判断今天、近一月
|
|
|
+ if (!beginTime.equals("")) {
|
|
|
+ String time = beginTime.trim() + " 00:00:00";
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(time));
|
|
|
+ }
|
|
|
+ if (!endTime.equals("")) {
|
|
|
+ String time = endTime.trim() + " 23:59:59";
|
|
|
+ qc.setEndTime(Timestamp.valueOf(time));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (offset == -1) {
|
|
|
+ if (isEmpty(beginTime))
|
|
|
+ beginTime = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ if (isEmpty(endTime))
|
|
|
+ endTime = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+
|
|
|
+ endTime = DateUtil.addDay(endTime, "yyyy-MM-dd", 1);
|
|
|
+ } else {
|
|
|
+ String today = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ beginTime = DateUtil.addDay(today, "yyyy-MM-dd", -offset);
|
|
|
+ endTime = DateUtil.addDay(today, "yyyy-MM-dd", 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 封装查询条件
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ qc.setP(p);
|
|
|
+ qc.setBegin(begin);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ qc.setBeginTime(sdf.parse(beginTime));
|
|
|
+ qc.setEndTime(sdf.parse(endTime));
|
|
|
+
|
|
|
+
|
|
|
+ if (!"ALLINSTORE".equals(type) && !"ALLDISPATCH".equals(type)
|
|
|
+ && !"ALL".equals(type) && !"INDEX".equals(type)
|
|
|
+ && !"WHITELIST".equals(type) && !"NOSTORE".equals(type)) {
|
|
|
+ qc.setStatusTime(beginTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ String subSql = "";
|
|
|
+ if (!"WHITELIST".equals(type)) {
|
|
|
+ subSql = getSubSql(expcode, queryType);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!subSql.equals("")) {
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+ }
|
|
|
+
|
|
|
+ qc.setExpId(expId);
|
|
|
+ qc.setShelfId(shelfId);
|
|
|
+
|
|
|
+ QueryPageDto pageDto = null;
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ pageDto = deliveryService.getQueryPageDto(qc);
|
|
|
+ if (pageDto.getPageList() != null) {
|
|
|
+ return Integer.parseInt(String.valueOf(pageDto.getPageList().getTotal()));
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getSubSql(String expcode, int queryType) {
|
|
|
+ String subSql = "";
|
|
|
+ if (null == expcode || "".equals(expcode)) {
|
|
|
+ return subSql;
|
|
|
+ }
|
|
|
+ String strRev = cn.haliaeetus.framework.util.StringUtil.stringReverse(expcode);
|
|
|
+ if (isNotEmpty(expcode)) {
|
|
|
+ if (queryType == 1) {
|
|
|
+ subSql += " and revexpCode like '" + strRev + "%'";
|
|
|
+ } else if (queryType == 2) {
|
|
|
+ subSql += " and revuserPhone like '" + strRev
|
|
|
+ + "%'";
|
|
|
+ } else if (queryType == 3) {
|
|
|
+ subSql += " and shelfCode = '" + expcode + "'";
|
|
|
+ } else if (queryType == 4) {
|
|
|
+ subSql += " and userName = '" + expcode + "'";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return subSql;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询短信
|
|
|
+ private int getNotSendAmount(int storeId, List<ExpressType> expressList, String beginTime, String endTime, int type) throws ParseException {
|
|
|
+ int p = 1;
|
|
|
+ int pageSize = 20000;
|
|
|
+ int begin = (p - 1) * pageSize;
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ qc.setP(p);
|
|
|
+ qc.setBegin(begin);
|
|
|
+
|
|
|
+ qc.setSmsStatus(type);
|
|
|
+
|
|
|
+ qc.setExpId(0);
|
|
|
+ qc.setShelfId(0);
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(beginTime));
|
|
|
+ qc.setEndTime(Timestamp.valueOf(endTime));
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ // String subSql = getSubSql("", 1);
|
|
|
+// if (!subSql.equals("")) {
|
|
|
+// qc.setSubSql(subSql);
|
|
|
+// }
|
|
|
+ String subSql = " and userPhone > ''";
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+
|
|
|
+ qc.setPageSize(pageSize);
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ //只查在库单子
|
|
|
+ statusList.add(122);
|
|
|
+ statusList.add(124);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ //只查有手机号的单子
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ QueryPageDto pageDto = deliveryService.getSmsFail4Page(qc, expressList);
|
|
|
+ PagedList<DeliveryDto> deliveryPagedList = pageDto.getPageList();
|
|
|
+ //统计未未通知数据
|
|
|
+ int count = 0;
|
|
|
+ //根据店铺id查询当前店铺的白名单客户
|
|
|
+ List<WhiteList> list = whiteListService.getByStoreId(storeId);
|
|
|
+ Map map = new HashMap();
|
|
|
+ for (WhiteList white : list) {
|
|
|
+ map.put(white.getUsermobile(), white);
|
|
|
+ }
|
|
|
+ List<DeliveryDto> items = deliveryPagedList.getItems();
|
|
|
+ for (DeliveryDto item : items) {
|
|
|
+ if (map.get(item.getDelivery().getUserPhone()) != null) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ count++;
|
|
|
+// jdo.setSmsStatus(d1.getSmsStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+// return deliveryPagedList.getItems().size();
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getNoArriveSubSql(String expcode, int queryType) {
|
|
|
+
|
|
|
+ String strRev = cn.haliaeetus.framework.util.StringUtil.stringReverse(expcode);
|
|
|
+ String subSql = "";
|
|
|
+ if (isNotEmpty(expcode)) {
|
|
|
+ if (queryType == 1) {
|
|
|
+ subSql += " and (expCode like '" + expcode + "%' or revexpCode like '" + strRev + "%')";
|
|
|
+ } else if (queryType == 2) {
|
|
|
+ subSql += " and (userPhone like '" + expcode + "%' or revuserPhone like '" + strRev
|
|
|
+ + "%')";
|
|
|
+ } else if (queryType == 4) {
|
|
|
+ subSql += " and userName = '" + expcode + "'";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return subSql;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<JDeliveryDto> getJDeliveryDto(PagedList<DeliveryDto> d, Map map, String pageType) {
|
|
|
+ List<JDeliveryDto> jdos = new ArrayList<JDeliveryDto>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ List<DeliveryDto> dto1 = d.getItems();
|
|
|
+ for (DeliveryDto d1 : dto1) {
|
|
|
+ JDeliveryDto jdo = new JDeliveryDto();
|
|
|
+ ExpressType exp = d1.getExpress();
|
|
|
+ Delivery d2 = d1.getDelivery();
|
|
|
+ //判断是否有白名单用户,存在直接跳过不显示
|
|
|
+ /*if(map.get(d2.getUserPhone()) != null){
|
|
|
+ continue;
|
|
|
+ }else{*/
|
|
|
+ //判断是否有白名单用户,存在直接跳过不显示
|
|
|
+ if (map.get(d2.getUserPhone()) != null) {
|
|
|
+ //判断是否是未通知接口,不显示白名单用户
|
|
|
+ if (Integer.parseInt(pageType) == -1) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //白名单用户状态为3,不发送短信
|
|
|
+ jdo.setSmsStatus(3);
|
|
|
+ jdo.setIsSendSMS(1);
|
|
|
+ } else {
|
|
|
+ jdo.setSmsStatus(d1.getSmsStatus());
|
|
|
+ if (d2.getStatus() == 122 || d2.getStatus() == 225) {
|
|
|
+ jdo.setIsSendSMS(0);
|
|
|
+ } else {
|
|
|
+ jdo.setIsSendSMS(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ jdo.setId(d2.getId());
|
|
|
+ jdo.setExpcode(d2.getExpcode());
|
|
|
+ jdo.setExpId(exp.getExpId());
|
|
|
+ jdo.setShelfCode(d2.getShelfCode());
|
|
|
+ if (null != d2.getSignDtm() && !"".equals(d2.getSignDtm())) {
|
|
|
+ jdo.setSignDtm(sdf.format(d2.getSignDtm()));
|
|
|
+ }
|
|
|
+ jdo.setExpName(exp.getExpName());
|
|
|
+ jdo.setStatus(d2.getStatus());
|
|
|
+ jdo.setUserPhone(d2.getUserPhone());
|
|
|
+ /*jdo.setSmsStatus(d1.getSmsStatus());*/
|
|
|
+ jdo.setShelfId(d2.getShelfId());
|
|
|
+ jdo.setDeliveryUid(d2.getDeliveryUid());
|
|
|
+ jdo.setDeliveryUname(d2.getDeliveryUname());
|
|
|
+ jdo.setShelfName(d1.getShelf().getShelfName());
|
|
|
+ jdo.setSendBackReason(d2.getSendBackReason());
|
|
|
+ if (null != d2.getUploadDtm() && !"".equals(d2.getUploadDtm())) {
|
|
|
+ jdo.setUploadDtm(sdf.format(d2.getUploadDtm()));
|
|
|
+ }
|
|
|
+ if (null != d2.getCreateTime() && !"".equals(d2.getCreateTime())) {
|
|
|
+ jdo.setCreateTime(sdf.format(d2.getCreateTime()));
|
|
|
+ }
|
|
|
+ if (null != d2.getSignDtm() && !"".equals(d2.getSignDtm())) {
|
|
|
+ jdo.setSignDtm(sdf.format(d2.getSignDtm()));
|
|
|
+ }
|
|
|
+ if (null != d1.getResultInfo() && !"".equals(d1.getResultInfo())) {
|
|
|
+ switch (d1.getSmsStatus()) {
|
|
|
+ case 1:
|
|
|
+ jdo.setResultInfo("");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ jdo.setResultInfo(SMSErrorCodeEnum.of(d1.getResultInfo()));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ jdo.setResultInfo("");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ jdo.setResultInfo("");
|
|
|
+ }
|
|
|
+ jdo.setReturnSignStatus(StatusCodeEnum.of(d1.getDelivery().getReturnSignStatus()));
|
|
|
+ if (null == d1.getSendSuccessType()) {
|
|
|
+ jdo.setSendSuccessType(0);
|
|
|
+ } else {
|
|
|
+ jdo.setSendSuccessType(d1.getSendSuccessType());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ jdos.add(jdo);
|
|
|
+
|
|
|
+ }
|
|
|
+ return jdos;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void pageDtos(QueryPageDto pageDto) {
|
|
|
+ for (DeliveryDto d : pageDto.getPageList().getItems()) {
|
|
|
+ List<DeliveryScanBatch> deliveryScanBatches = scanBatchService.getByCondition(d.getDelivery().getStoreId(), d.getDelivery().getExpcode(), d.getDelivery().getExpId(), null, null, null);
|
|
|
+ if (d.getDelivery().getUserPhone() != null) {
|
|
|
+ if (deliveryScanBatches.size() > 0 && "2".equals(deliveryScanBatches.get(0).getOcrStatus())) {
|
|
|
+ StringBuilder number = new StringBuilder(d.getDelivery().getUserPhone());
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(d.getDelivery().getUserPhone()) || org.apache.commons.lang.StringUtils.isBlank(d.getDelivery().getUserPhone())) {
|
|
|
+ number.append("");
|
|
|
+ } else {
|
|
|
+ number.replace(3, 10, "*******");
|
|
|
+ }
|
|
|
+ //number.replace(3, 10, "*******");
|
|
|
+ d.getDelivery().setUserPhone(number.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getSpecifiedDayAfter(String specifiedDay) {
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ Date date = null;
|
|
|
+ try {
|
|
|
+ date = new SimpleDateFormat("yyyy-MM-dd").parse(specifiedDay);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ c.setTime(date);
|
|
|
+ int day = c.get(Calendar.DATE);
|
|
|
+ c.set(Calendar.DATE, day + 1);
|
|
|
+
|
|
|
+ String dayAfter = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
|
|
|
+ return dayAfter;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long getSignStatusCount(int storeId) throws ParseException {
|
|
|
+ String beginTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String endTime1 = DateUtil.today().toString("yyyy-MM-dd");
|
|
|
+ String time1 = beginTime1.trim() + " 00:00:00";
|
|
|
+ String time2 = endTime1.trim() + " 23:59:59";
|
|
|
+ endTime1 = DateUtil.addDay(endTime1, "yyyy-MM-dd", 1);
|
|
|
+ DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ qc.setBeginTime(formatter.parse(time1));
|
|
|
+ qc.setEndTime(formatter.parse(time2));
|
|
|
+ qc.setCreateTime(beginTime1, endTime1);
|
|
|
+ //qc.setSignStatus("0");
|
|
|
+ //update 20190411 防止申通代签之类的状态查询不到
|
|
|
+ qc.setSignStatus(null);
|
|
|
+ ArrayList<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ //statusList.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_DISPATCHING);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_MAIKE_DISPATCHING);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_PICK_UP);
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ long count = deliveryService.getCount(qc);
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询短信
|
|
|
+ private Map<Integer, Integer> smsCountMap(int storeId, List<ExpressType> expressList, String beginTime, String endTime) throws ParseException {
|
|
|
+ int p = 1;
|
|
|
+ int pageSize = 20000;
|
|
|
+ int begin = (p - 1) * pageSize;
|
|
|
+ DeliveryQueryCondition qc = getDeliveryQueryCondition(storeId);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ qc.setP(p);
|
|
|
+ qc.setBegin(begin);
|
|
|
+
|
|
|
+ qc.setExpId(0);
|
|
|
+ qc.setShelfId(0);
|
|
|
+ qc.setBeginTime(Timestamp.valueOf(beginTime));
|
|
|
+ qc.setEndTime(Timestamp.valueOf(endTime));
|
|
|
+ qc.setCreateTime(beginTime, endTime);
|
|
|
+
|
|
|
+ qc.setOrderField("createTime");
|
|
|
+ qc.setOrder("desc");
|
|
|
+ String subSql = getSubSql("", 1);
|
|
|
+// if (!subSql.equals("")) {
|
|
|
+// qc.setSubSql(subSql);
|
|
|
+// }
|
|
|
+ // subSql += " and userPhone > '' and odeliveryType<>'PS' ";
|
|
|
+ subSql += " and userPhone > ''";
|
|
|
+ qc.setSubSql(subSql);
|
|
|
+
|
|
|
+
|
|
|
+ qc.setPageSize(pageSize);
|
|
|
+ List<Integer> statusList = new ArrayList<Integer>();
|
|
|
+ //只查在库单子
|
|
|
+ statusList.add(122);
|
|
|
+ statusList.add(124);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ //只查有手机号的单子
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+ Map<Integer, Integer> smsCountMap = deliveryService.getSmsFailCount(qc, expressList);
|
|
|
+ return smsCountMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*@RequestMapping(value = {"/chargeBack"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object chargeBack(HttpServletRequest request,@RequestParam(defaultValue = "")String param) throws Exception{
|
|
|
+ User user = userService.getUserById(request.getParameter(COOKIE_USERID));
|
|
|
+ if(null == user){
|
|
|
+ return buildJson(1,"用户未登录");
|
|
|
+ }
|
|
|
+ Date nowDate=new Date();
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ if(null==param||"".equals(param)){
|
|
|
+ calendar.setTime(nowDate);
|
|
|
+ }else{
|
|
|
+ calendar.setTime(sdf.parse(param));
|
|
|
+ }
|
|
|
+ calendar.add(Calendar.DATE, -1); //得到前一天
|
|
|
+ Date date = calendar.getTime();
|
|
|
+ String yestedayDate=sdf.format(date);
|
|
|
+ String beginTime=yestedayDate.trim()+" 00:00:00";
|
|
|
+ String endTime = yestedayDate.trim()+" 23:59:59";
|
|
|
+
|
|
|
+ *//*List<User> users=userDao.getAllUser();*//*
|
|
|
+
|
|
|
+ *//*User user = getUserFromParam(request);*//*
|
|
|
+ *//*for (User user : users) {*//*
|
|
|
+ //判断是否有失败返额记录
|
|
|
+ List<ConsumeRecord> chargeRecord = consumeRecordService.getChargeRecord(user.getStoreId(), beginTime);
|
|
|
+ if (chargeRecord.size() == 0) {
|
|
|
+
|
|
|
+ //根据门店Id查询当天的返还金额
|
|
|
+ BigDecimal nowBalance = smsRecordService.getChargeCount(user.getStoreId(), beginTime, endTime, user.getSmsPrice());
|
|
|
+
|
|
|
+ ConsumeRecord consumeRecord = new ConsumeRecord();
|
|
|
+ consumeRecord.setConsumeFlag("5");//0代表ocr,1代表短信//2代表充值//5代表发送短信失败返还
|
|
|
+ *//*consumeRecord.setSmsId(String.valueOf(smsRecord.getId()));*//*
|
|
|
+ log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++开始插入消费记录表");
|
|
|
+ consumeRecord.setSmsId("");
|
|
|
+ consumeRecord.setOcrId("");
|
|
|
+ consumeRecord.setStoreId(user.getStoreId());
|
|
|
+ consumeRecord.setExpcode("");
|
|
|
+ consumeRecord.setExpId(0);
|
|
|
+ consumeRecord.setCreateTime(new Date());
|
|
|
+ consumeRecord.setConsumeStatus("1");//消费失败,余额不够发送短信
|
|
|
+ consumeRecord.setOperatorId(BigDecimal.valueOf(Long.valueOf(user.getUserId())));
|
|
|
+ consumeRecord.setPreBalance(user.getSmsBalance());
|
|
|
+ consumeRecord.setAftBalance(user.getSmsBalance().add(nowBalance));
|
|
|
+ consumeRecord.setNowAmount(nowBalance);
|
|
|
+ consumeRecordService.save(consumeRecord);
|
|
|
+
|
|
|
+ UserQueryCondition condition = new UserQueryCondition();
|
|
|
+ condition.setUserId(user.getUserId());
|
|
|
+ user.setSmsBalance(user.getSmsBalance().add(nowBalance));
|
|
|
+ log.info("AMOUNT::::::::" + user.getSmsBalance());
|
|
|
+ condition.setEntity(user);
|
|
|
+ userService.updateUser(condition);
|
|
|
+ //add 2019-04-022
|
|
|
+ CacheTool cacheTool = CacheTool.initUser();
|
|
|
+ cacheTool.saveBean(user.getUserId(), user);
|
|
|
+ } else {
|
|
|
+ log.info("SSSSSSSSSSSSSSS:昨天失败短信已经返现");
|
|
|
+ return "SUCCESS";
|
|
|
+// }
|
|
|
+ }
|
|
|
+ return "SUCCESS";
|
|
|
+ }
|
|
|
+*/
|
|
|
+
|
|
|
+ @RequestMapping(value = {"/app/api/v1/query"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object queryFromES(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam(defaultValue = "1") String p,//第几页
|
|
|
+ @RequestParam(defaultValue = "20") String pageSize,//每页多少
|
|
|
+ @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
|
|
|
+ @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
|
|
|
+ @RequestParam(defaultValue = "ALL") String type,//All全部 未入库,已到库,已出库
|
|
|
+ @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
|
|
|
+ @RequestParam(defaultValue = "0") String shelfId,//
|
|
|
+ @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
|
|
|
+ @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
|
|
|
+ @RequestParam(defaultValue = "") String expcode,
|
|
|
+ @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
|
|
|
+ @RequestParam(defaultValue = "-1") String search,
|
|
|
+ @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
|
|
|
+ @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
|
|
|
+ @RequestParam(defaultValue = "-1") String sort) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+
|
|
|
+ if (!accessLimitService.tryAcquire()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+ String userId = request.getParameter(COOKIE_USERID);
|
|
|
+ StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
|
|
|
+ if (storeReqLimit.getIsLimitFlag()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ if (user == null) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取门店id并封装进查询条件
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+
|
|
|
+ // 用于封装查询条件
|
|
|
+ ESDeliveryQueryCondition condition = new ESDeliveryQueryCondition();
|
|
|
+ // 设置门店id
|
|
|
+ condition.setStoreId(storeId);
|
|
|
+
|
|
|
+ // 设置分页
|
|
|
+ int p1 = Integer.parseInt(p);
|
|
|
+ p1 = max(1, p1);
|
|
|
+ int begin = (p1 - 1) * Integer.parseInt(pageSize);
|
|
|
+ condition.setP(p1);
|
|
|
+ condition.setBegin(begin);
|
|
|
+ condition.setPageSize(Integer.parseInt(pageSize));
|
|
|
+
|
|
|
+ // 设置日期查询条件
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ if (null == beginTime || "".equals(beginTime.trim())) {
|
|
|
+ beginTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ condition.setBeginTime(sdf.parse(beginTime.trim()));
|
|
|
+
|
|
|
+ if (null == endTime || "".equals(endTime.trim())) {
|
|
|
+ endTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ condition.setEndTime(sdf.parse(DateUtil.addDay(endTime, "yyyy-MM-dd", 1)));
|
|
|
+
|
|
|
+ if ("短信".equals(smsType) || "1".equals(smsType)) {
|
|
|
+ condition.setSendSuccessType(new int[]{1});
|
|
|
+ } else if ("微信".equals(smsType) || "2".equals(smsType)) {
|
|
|
+ condition.setSendSuccessType(new int[]{2});
|
|
|
+ }
|
|
|
+
|
|
|
+ // condition.setExpId(Integer.valueOf(expId));
|
|
|
+ // condition.setShelfId(Integer.valueOf(shelfId));
|
|
|
+
|
|
|
+ // 判断是依据面单号/用户手机/取件码查询
|
|
|
+ switch (Integer.valueOf(queryType)) {
|
|
|
+ case 1:
|
|
|
+ condition.setExpcode(expcode);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ condition.setUserPhone(expcode);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ condition.setShelfCode(expcode);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ // 未通知
|
|
|
+ if ("-1".equals(pageType)) {
|
|
|
+ // 只查在库,滞留单子
|
|
|
+ condition.setStatus(new int[]{Constants.ORDER_STATUS_STORED,Constants.ORDER_STATUS_REJECT_RETENTION});
|
|
|
+ // 快件查询 and 通知管理
|
|
|
+ } else {
|
|
|
+ condition.setStatus(new int[] {
|
|
|
+ Constants.ORDER_STATUS_STORED, Constants.ORDER_STATUS_DISPATCHING,
|
|
|
+ Constants.ORDER_STATUS_REJECT_RETENTION, Constants.ORDER_STATUS_COMPLETE,
|
|
|
+ Constants.ORDER_STATUS_LEAVE_STORE});
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否是未通知接口,不显示白名单用户
|
|
|
+ if(null != pageType && ("-1".equals(pageType) || "1".equals(pageType))){
|
|
|
+ condition.setWhiteUser(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Integer.valueOf(smsStatus) != -2 && Integer.valueOf(smsStatus) != 3) {
|
|
|
+ // "0": 已通知-包含发送成功的和发送失败的,1:发送成功,2:发送失败
|
|
|
+ if ("0".equals(smsStatus)) {
|
|
|
+ condition.setSmsStatus(new int[]{1, 2});
|
|
|
+ } else {
|
|
|
+ condition.setSmsStatus(new int[]{Integer.parseInt(smsStatus)});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonMsg jsonMsg = deliveryService.queryDeliveries(condition);
|
|
|
+ if(null == jsonMsg){
|
|
|
+ try {
|
|
|
+ return newQuery(request,p,pageSize,beginTime,endTime,type,expId,shelfId,smsType,smsStatus,expcode,queryType,search,pageType,requestSign,sort);
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonMsg.add("requestSign", requestSign);
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @throws
|
|
|
+ * @description
|
|
|
+ * @author sunjj
|
|
|
+ * @updateTime
|
|
|
+ */
|
|
|
+ @RequestMapping(value = {"/app/api/v1/query/new"})
|
|
|
+ @ResponseBody
|
|
|
+ public Object newQuery(HttpServletRequest request,
|
|
|
+ @RequestParam(defaultValue = "1") String p,//第几页
|
|
|
+ @RequestParam(defaultValue = "20") String pageSize,//每页多少
|
|
|
+ @RequestParam(defaultValue = "") String beginTime,//查询入库开始时间
|
|
|
+ @RequestParam(defaultValue = "") String endTime,//查询入库结束时间
|
|
|
+ @RequestParam(defaultValue = "ALL") String type,//All全部 未入库,已到库,已出库
|
|
|
+ @RequestParam(defaultValue = "0") String expId,//快递公司,手机号
|
|
|
+ @RequestParam(defaultValue = "0") String shelfId,//
|
|
|
+ @RequestParam(defaultValue = "") String smsType,//通知类型短信或者微信
|
|
|
+ @RequestParam(defaultValue = "-2") String smsStatus,//通知状态
|
|
|
+ @RequestParam(defaultValue = "") String expcode,
|
|
|
+ @RequestParam(defaultValue = "1") String queryType,//查询类型1面单号
|
|
|
+ @RequestParam(defaultValue = "-1") String search,
|
|
|
+ @RequestParam(defaultValue = "-1") String pageType,//页面访问类型
|
|
|
+ @RequestParam(defaultValue = "-1") String requestSign,//解决查询结果出错的
|
|
|
+ @RequestParam(defaultValue = "-1") String sort) throws SQLException,
|
|
|
+ ParseException {
|
|
|
+ if (!accessLimitService.tryAcquire()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+ String userId = request.getParameter(COOKIE_USERID);
|
|
|
+ StoreReqLimit storeReqLimit = basicInfoService.getStoreReqLimitByUserId(userId + "query");
|
|
|
+ if (storeReqLimit.getIsLimitFlag()) {
|
|
|
+ return buildJson(1, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = getUserFromParam(request);
|
|
|
+ if (user == null) {
|
|
|
+ return buildJson(1, "用户未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ int storeId = user.getStoreId();
|
|
|
+
|
|
|
+ DeliveryQueryCondition qc = new DeliveryQueryCondition(storeId);
|
|
|
+
|
|
|
+ // 计算分页条件
|
|
|
+ int page = max(1, Integer.parseInt(p));
|
|
|
+ int pageCount = Integer.parseInt(pageSize);
|
|
|
+ int begin = (page - 1) * Integer.parseInt(pageSize);
|
|
|
+ qc.setP(page);
|
|
|
+ qc.setBegin(begin);
|
|
|
+ qc.setPageSize(pageCount);
|
|
|
+
|
|
|
+ // 计算查询时间
|
|
|
+ String pattern = "yyyy-MM-dd";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ Date beginDate = null;
|
|
|
+ if (null == beginTime || "".equals(beginTime)) {
|
|
|
+ beginTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ beginDate = Timestamp.valueOf(beginTime + " 00:00:00");
|
|
|
+
|
|
|
+ Date endDate = null;
|
|
|
+ if (null == endTime || "".equals(endTime)) {
|
|
|
+ endTime = sdf.format(date);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ endTime = DateUtil.addDay(endTime, pattern, 1);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ endDate = Timestamp.valueOf(endTime + " 00:00:00");
|
|
|
+
|
|
|
+ qc.setBeginTime(beginDate);
|
|
|
+ qc.setEndTime(endDate);
|
|
|
+
|
|
|
+ if ("短信".equals(smsType) || "1".equals(smsType)) {
|
|
|
+ qc.setSmsType(1);
|
|
|
+ } else if ("微信".equals(smsType) || "2".equals(smsType)) {
|
|
|
+ qc.setSmsType(2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!"-2".equals(smsStatus) && !"3".equals(smsStatus)) {
|
|
|
+ qc.setSmsStatus(Integer.valueOf(smsStatus));
|
|
|
+ } else {
|
|
|
+ qc.setSmsStatus(3);
|
|
|
+ }
|
|
|
+
|
|
|
+ //状态和类型没处理
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 未通知
|
|
|
+ if ("-1".equals(pageType)) {
|
|
|
+ //只查在库单子
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ //滞留
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+
|
|
|
+ // 快件查询 and 通知管理
|
|
|
+ } else {
|
|
|
+ //只查在库单子
|
|
|
+ statusList.add(Constants.ORDER_STATUS_STORED);
|
|
|
+ //滞留
|
|
|
+ statusList.add(Constants.ORDER_STATUS_DISPATCHING);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_REJECT_RETENTION);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_COMPLETE);
|
|
|
+ statusList.add(Constants.ORDER_STATUS_LEAVE_STORE);
|
|
|
+ }
|
|
|
+ qc.setStatusStr(statusList);
|
|
|
+
|
|
|
+ if (isNotEmpty(expcode)) {
|
|
|
+ int len = expcode.length();
|
|
|
+ switch (queryType) {
|
|
|
+ // 根据面单号查询
|
|
|
+ case "1":
|
|
|
+ if (len > 7) {
|
|
|
+ qc.setExpcode(expcode);
|
|
|
+ } else if (len > 4) {
|
|
|
+ qc.setRevexpCode(expcode.substring(len - 4));
|
|
|
+ } else {
|
|
|
+ qc.setRevexpCode(expcode);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ // 根据用户手机号查询
|
|
|
+ case "2":
|
|
|
+ if (len == 11) {
|
|
|
+ qc.setUserPhone(expcode);
|
|
|
+ } else if (expcode.length() > 4) {
|
|
|
+ qc.setRevuserPhone(expcode.substring(len - 4));
|
|
|
+ } else {
|
|
|
+ qc.setRevuserPhone(expcode);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ // 根据取件码查询
|
|
|
+ case "3":
|
|
|
+ qc.setShelfCode(expcode);
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ qc.setUserName(expcode);
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否是未通知接口,不显示白名单用户
|
|
|
+ if (null != pageType && !"".equals(pageType) && (Integer.parseInt(pageType) == -1 || Integer.parseInt(pageType) == 1)) {
|
|
|
+ qc.setIswhite(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ JsonMsg jsonMsg = deliveryService.queryDeliveries(qc, pageType);
|
|
|
+ jsonMsg.add("requestSign", requestSign);
|
|
|
+ return jsonMsg;
|
|
|
+ }
|
|
|
+}
|