Java tutorial
package com.consult.app.controller; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.map.HashedMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Controller; import org.springframework.util.StringUtils; 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 com.consult.app.async.AsyncProcess; import com.consult.app.bo.AccountBo; import com.consult.app.bo.AccountLogBo; import com.consult.app.bo.AdminBo; import com.consult.app.bo.AdminLogBo; import com.consult.app.bo.CargoBonusListBo; import com.consult.app.bo.CargoMessageBo; import com.consult.app.bo.CertificateBo; import com.consult.app.bo.CityBo; import com.consult.app.bo.ClientBo; import com.consult.app.bo.ExtensionTelephoneBo; import com.consult.app.bo.FixedMessageBo; import com.consult.app.bo.InternalUserBo; import com.consult.app.bo.LocateLogBo; import com.consult.app.bo.OrderBo; import com.consult.app.bo.PartTimerBo; import com.consult.app.bo.PayBo; import com.consult.app.bo.PolicyOrderBo; import com.consult.app.bo.PositionBo; import com.consult.app.bo.PositionLogBo; import com.consult.app.bo.PositionRequestBo; import com.consult.app.bo.ProfileBakBo; import com.consult.app.bo.ProfileBo; import com.consult.app.bo.PublishVisitLogsBo; import com.consult.app.bo.PublishVisitUserBo; import com.consult.app.bo.PublisherBo; import com.consult.app.bo.SalesmanBo; import com.consult.app.bo.SalesmanClientBo; import com.consult.app.bo.TruckMessageBo; import com.consult.app.bo.UnregisterUserBo; import com.consult.app.bo.UploadLogBo; import com.consult.app.bo.UserBo; import com.consult.app.bo.UserDirectionBo; import com.consult.app.bo.UserOriginBo; import com.consult.app.bo.VerifyBo; import com.consult.app.bo.WXQrcBo; import com.consult.app.bo.WithDrawBo; import com.consult.app.bo.WithDrawTaskBo; import com.consult.app.modal.Account; import com.consult.app.modal.AdminLog; import com.consult.app.modal.CargoBonusList; import com.consult.app.modal.CargoMessage; import com.consult.app.modal.Certificate; import com.consult.app.modal.City; import com.consult.app.modal.Client; import com.consult.app.modal.ExtensionTelephone; import com.consult.app.modal.LocateLog; import com.consult.app.modal.PartTimer; import com.consult.app.modal.Position; import com.consult.app.modal.PositionLog; import com.consult.app.modal.PositionRequest; import com.consult.app.modal.Profile; import com.consult.app.modal.ProfileBak; import com.consult.app.modal.PublishVisitLogs; import com.consult.app.modal.PublishVisitUser; import com.consult.app.modal.Publisher; import com.consult.app.modal.Salesman; import com.consult.app.modal.UnregisterUser; import com.consult.app.modal.User; import com.consult.app.modal.UserDirection; import com.consult.app.modal.UserOrigin; import com.consult.app.modal.WXQrc; import com.consult.app.modal.WithDraw; import com.consult.app.request.BeforeAfterRequest; import com.consult.app.request.CityCountRequest; import com.consult.app.request.IdBeforeAfterRequest; import com.consult.app.request.IdCityRequest; import com.consult.app.request.IdRequest; import com.consult.app.request.IdTypeBeforeAfterRequest; import com.consult.app.request.TelephoneCityRequest; import com.consult.app.request.TokenRequest; import com.consult.app.request.TypeBeforeAfterRequest; import com.consult.app.request.TypeRequest; import com.consult.app.request.UpdateTimeIdRequest; import com.consult.app.request.UpdateTimeRequest; import com.consult.app.request.admin.AddCallRequest; import com.consult.app.request.admin.BindExtensionRequest; import com.consult.app.request.admin.BindQrcRequest; import com.consult.app.request.admin.ChangeAccountRequest; import com.consult.app.request.admin.ChangeTelephoneRequest; import com.consult.app.request.admin.GetBunchWithDrawDetailsRequest; import com.consult.app.request.admin.GetCargosRequest; import com.consult.app.request.admin.InitInternalUserRequest; import com.consult.app.request.admin.LoginRequest; import com.consult.app.request.admin.ModifyPublisherRequest; import com.consult.app.request.admin.NewAdminRequest; import com.consult.app.request.admin.NewCargoRequest; import com.consult.app.request.admin.ProcessWithdrawRequest; import com.consult.app.request.admin.PublishCallRequest; import com.consult.app.request.admin.SearchExtensionRequest; import com.consult.app.request.admin.SetBlackRequest; import com.consult.app.request.admin.TelephoneBeforeAfterRequest; import com.consult.app.request.cargo.SmsTriggerRequest; import com.consult.app.request.pay.ModifyCargoMemberRequest; import com.consult.app.request.pay.UpdateAccountRequest; import com.consult.app.request.pay.UpdateMemberRequest; import com.consult.app.request.policy.PolicyOrderBeforeAfterRequest; import com.consult.app.request.user.CompleteUnregisterRequest; import com.consult.app.request.user.ModifyInfoRequest; import com.consult.app.request.user.PostPositionRequest; import com.consult.app.request.user.ProcessPositionRequest; import com.consult.app.request.user.SearchPositionRequest; import com.consult.app.request.user.TelephoneRequest; import com.consult.app.response.BaseResponse; import com.consult.app.response.CountResponse; import com.consult.app.response.IdResultResponse; import com.consult.app.response.IdUpdateTimeResultResponse; import com.consult.app.response.PictureUploadResponse; import com.consult.app.response.ResultObjectResponse; import com.consult.app.response.ResultResponse; import com.consult.app.response.UpdateTimeResultResponse; import com.consult.app.response.admin.AdminLoginResponse; import com.consult.app.response.admin.GetSmsLocateResponse; import com.consult.app.response.admin.UserInfo; import com.consult.app.response.pay.AccountItem; import com.consult.app.response.pay.BonusCargoItem; import com.consult.app.response.pay.WebPayLogResponse; import com.consult.app.response.policy.GetPolicyOrderListResponse; import com.consult.app.response.pos.LineItem; import com.consult.app.response.pos.ParseUnregisterLinesResponse; import com.consult.app.response.publisher.UserTypeItem; import com.consult.app.response.sales.ClientItem; import com.consult.app.response.sales.IdItem; import com.consult.app.response.sales.SalesmanInfo; import com.consult.app.response.user.CargoMessageAuthItem; import com.consult.app.response.user.GetInfoResponse; import com.consult.app.response.user.GetMessagesResponse; import com.consult.app.response.user.PositionInfo; import com.consult.app.sms.SendSmsUtil; import com.consult.app.utils.Constant; import com.consult.app.utils.Cookie; import com.consult.app.utils.CurrentStatusManager; import com.consult.app.utils.FakeShipperCounter; import com.consult.app.utils.LogUtil; import com.consult.app.utils.MessageDigestGenerator; import com.consult.app.utils.PositionHelper; import com.consult.app.utils.RandomNumber; import com.consult.app.utils.TimeUtils; @Controller @RequestMapping("/web/*") @Configuration @ComponentScan("com.consult.app.bo") // No need to include component-scan in xml public class WebController { @Autowired private CityBo cityBo; @Autowired private UserBo userBo; @Autowired private VerifyBo verifyBo; @Autowired private ProfileBo profileBo; @Autowired private UploadLogBo uploadLogBo; @Autowired private FixedMessageBo fixedMessageBo; @Autowired private TruckMessageBo truckMessageBo; @Autowired private CargoMessageBo cargoMessageBo; @Autowired private AsyncProcess asyncProcess; @Autowired private PublisherBo publisherBo; @Autowired private AdminBo adminBo; @Autowired private AdminLogBo adminLogBo; @Autowired private ClientBo clientBo; @Autowired private UnregisterUserBo unregisterUserBo; @Autowired private PositionRequestBo positionRequestBo; @Autowired private UserDirectionBo userDirectionBo; @Autowired private UserOriginBo userOriginBo; @Autowired private CargoBonusListBo cargoBonusListBo; @Autowired private OrderBo orderBo; @Autowired private PositionLogBo positionLogBo; @Autowired private AccountBo accountBo; @Autowired private AccountLogBo accountLogBo; @Autowired private PayBo payBo; @Autowired private WithDrawTaskBo withDrawTaskBo; @Autowired private CertificateBo certificateBo; @Autowired private WXQrcBo wxqrcBo; @Autowired private SalesmanBo salesmanBo; @Autowired private SalesmanClientBo salesmanClientBo; @Autowired private PartTimerBo partTimerBo; @Autowired private ExtensionTelephoneBo extensionTelephoneBo; @Autowired private InternalUserBo internalUserBo; @Autowired private PublishVisitUserBo publishVisitUserBo; @Autowired private PublishVisitLogsBo publishVisitLogsBo; @Autowired private LocateLogBo locateLogBo; @Autowired private PolicyOrderBo policyOrderBo; @Autowired private PositionBo positionBo; @Autowired private ProfileBakBo profileBakBo; @Autowired private WithDrawBo withDrawBo; /** * * @author zhangqi * @param req * @return */ @RequestMapping(value = "loginp", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody AdminLoginResponse publisherlogin(@RequestBody LoginRequest req) { AdminLoginResponse rsp = new AdminLoginResponse((long) 0, Cookie.RESPONSE_WRONG_PASSWORD_OR_NAME); try { /** select **/ Publisher publisher = publisherBo.checkPublisher(req.getUserName(), MessageDigestGenerator.generateSHA256(req.getPassword())); if (publisher == null) { return rsp; } else { if (publisher.getType() == Constant.TYPE_NORMAL) { rsp.setId(Long.valueOf(publisher.getId())); rsp.setResult(Cookie.RESPONSE_SUCCESS); rsp.setRole(publisher.getRole()); } else { rsp.setResult(Cookie.RESPONSE_USER_UNAUTHORIZED); } return rsp; } } catch (Exception e) { e.printStackTrace(); rsp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); return rsp; } } /** * ??? * ??type=Constant.TYPE_XIWEI * @author zhangqi * @param NewCargoRequest * @return IdUpdateTimeResultResponse */ @RequestMapping(value = "newcargo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody IdUpdateTimeResultResponse newCargo(@RequestBody NewCargoRequest req, HttpServletResponse response, HttpServletRequest request) { IdUpdateTimeResultResponse rp = new IdUpdateTimeResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long userId = Cookie.checkPublishUser(strId); if (NewCargoRequest.checkParameters(req) <= 0) { return rp; } int start = req.getStart(), end = req.getEnd(); City startCity = cityBo.findById(start); City endCity = cityBo.findById(end); if (startCity == null || endCity == null) { return rp; } long now = System.currentTimeMillis(); // long endTime = now + req.getValidTime() * Constant.HOUR_IN_MILLI; if (req.getLandlines() == null) { req.setLandlines(""); } req.setDescription(req.getDescription() + Constant.DESCRIPTION_APPEND); if (!req.getDescription().endsWith(Constant.DESCRIPTION_APPEND)) { req.setDescription(req.getDescription() + Constant.DESCRIPTION_APPEND); } double truckLength = CargoMessage.parseTruckLength(req.getTruckLength(), 0); CargoMessage message = new CargoMessage(null, 0L, start, end, req.getTelephone(), req.getContact(), req.getWeight(), req.getCapacity(), truckLength, 0, Constant.TYPE_XIWEI, req.getDescription(), now, now, Constant.getCargoWeightRange(req.getWeight()), Constant.getTruckLengthRange(truckLength), req.getCompanyName(), req.getCompanyAddress(), endCity.getParentId(), endCity.getGrandId(), startCity.getParentId(), req.getLandlines(), startCity.getGrandId()); message.setTruckLengthSet(req.getTruckLength()); //????0-100? message.setMessageCount(Long.valueOf(RandomNumber.createRandomInt(100) + 1)); message.setRePublish(true);//??? if (req.getTelephone() != null && !req.getTelephone().equals("")) { try { Long telephone = Long.valueOf(req.getTelephone()); CargoMessageAuthItem item = userBo.getMessageAuthenticateByTel(telephone); if (item != null) { if (item.getUserType() == Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); return rp; } int authenticate = cargoBonusListBo.isMember(item.getUserId()) == true ? Constant.USER_AUTHENTICATE_SUCCESS : Constant.USER_AUTHENTICATE_FAIL; if (authenticate == Constant.USER_AUTHENTICATE_SUCCESS) { req.setDescription(""); } message.setScore(item.getScore()); message.setOrderCount(item.getOrderCount()); message.setUserId(item.getUserId()); message.setAvatarAuthenticate(authenticate); message.setLicenseAuthenticate(authenticate); message.setPicture(item.getPicture()); message.setCompanyAddress(item.getCompanyAddress()); message.setCompanyName(item.getCompanyName()); message.setContact(item.getUserName()); message.setLandlines(item.getLandlines()); message.setMessageCount(item.getMessageCount() + 1); asyncProcess.addMessageCount(item.getUserId(), 1, false); } else { message.setMessageCount( FakeShipperCounter.getInstance().getAndAdd(Long.valueOf(req.getTelephone()))); } } catch (Exception e) { e.printStackTrace(); } } else { message.setTelephone(req.getLandlines()); } if (1 != cargoMessageBo.save(message)) { rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); return rp; } /*//do redis*/ asyncProcess.processCargoToRedis(startCity, endCity, now, message); rp.setResult(Cookie.RESPONSE_SUCCESS); rp.setId(message.getMessageId()); rp.setUpdateTime(now); uploadLogBo.writeLog(userId, message.getMessageId(), Constant.MESSAGE_TYPE_CARGO, now); publisherBo.addMessageCount(userId); asyncProcess.processAdd(startCity, endCity, Constant.MESSAGE_TYPE_CARGO, "", now, message); return rp; } /** * ?? * @deprecated * @author zhangqi * @param TokenRequest * @return UpdateTimeResultResponse */ @RequestMapping(value = "msglogin", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody UpdateTimeResultResponse sendMsg(@RequestBody TokenRequest req) { UpdateTimeResultResponse rp = new UpdateTimeResultResponse(); String token = req.getToken(); if (token == null || token.equals("") || !token.equals(Constant.SEND_MESSAGE_TOKEN)) { rp.setResult(Cookie.RESPONSE_WRONG_PASSWORD_OR_NAME); return rp; } rp.setResult(Cookie.RESPONSE_SUCCESS); rp.setUpdateTime(System.currentTimeMillis()); return rp; } /** * ???app? * @deprecated * @author zhangqi * @param UpdateTimeRequest * @return GetMessagesResponse */ @RequestMapping(value = "getverifycodes", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getVerifyCodes(@RequestBody UpdateTimeRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); List<Object> list = verifyBo.getVerifyCodes(req); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * web? * @author zhangqi * @param Picture Map * @return String {"status":0/1} */ @RequestMapping(value = "upload", method = RequestMethod.POST) public @ResponseBody String upload(HttpServletRequest request, HttpServletResponse response) { try { @SuppressWarnings("unchecked") Map<String, String[]> map = request.getParameterMap(); String[] pictures = map.get("pic1"); if (pictures == null || pictures.length <= 0) { return "{\"status\":0}"; } String picture = pictures[0]; String[] str = map.get("t"); String token = str[0]; String strId = new String(Base64.decodeBase64(token.getBytes("UTF-8")), "UTF-8"); String[] hash = strId.split(":"); Long userId = Long.valueOf(Cookie.getRealCommonUserId(hash[0])); User user = userBo.findById(userId); if (user.getAvatarAuthenticate() != Constant.USER_AUTHENTICATE_SUCCESS && user.getAvatarAuthenticate() != Constant.USER_AUTHENTICATE_WAIT) { if (!user.getPassword().equals(MessageDigestGenerator.generateSHA256(hash[1]))) { return "{\"status\":0}"; } PictureUploadResponse rpp = Cookie.getUploadPictureUrlFromBash64(userId, picture, Constant.PICTURE_TYPE_AVATAR); if (rpp == null || rpp.getResult() != Cookie.RESPONSE_SUCCESS) { return "{\"status\":-1}"; } LogUtil.d("UPLOADPIC", "url=" + rpp.getPicture()); Profile profile = profileBo.findById(userId); profile.setPicture(rpp.getPicture()); profile.setUpdateTime(System.currentTimeMillis()); profileBo.update(profile); userBo.updateAuthenticate(userId, Constant.USER_AUTHENTICATE_WAIT, Constant.AUDIT_TYPE_AVATAR); LogUtil.d("UPLOADPIC", "status=1"); return "{\"status\":1}"; } else { LogUtil.d("UPLOADPIC", "status=-2"); return "{\"status\":-2}"; } } catch (IOException e) { e.printStackTrace(); } return "{\"status\":-1}"; } /** * ? * @author zhangqi * @param NewEnterpriseRequest * @return IdResultResponse */ @RequestMapping(value = "newpublisher", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody IdResultResponse newPublisher(@RequestBody NewAdminRequest req) { IdResultResponse rp = new IdResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); // int result = Cookie.checkAdminPermission(adminBo, Constant.ROLE_SUPER, adminId); // if(result != Cookie.RESPONSE_SUCCESS) { // rp.setResult(result); // return rp; // } if (NewAdminRequest.checkParameters(req) <= 0) { return rp; } long now = System.currentTimeMillis(); Publisher obj = new Publisher(); obj.setId(null); obj.setName(req.getName()); obj.setTelephone(req.getTelephone()); obj.setPassword(MessageDigestGenerator.generateSHA256(req.getPassword())); obj.setRole(req.getRole()); obj.setType(Constant.TYPE_NORMAL); obj.setCreateTime(now); obj.setUpdateTime(now); obj.setMessageCount(0); obj.setMessageTime(TimeUtils.getFormatedDate(now)); publisherBo.save(obj); rp.setResult(Cookie.RESPONSE_SUCCESS); rp.setId(Long.valueOf(obj.getId())); return rp; } /** * Modify Publisher Profile * @author zhangqi * @param ModifyPublisherRequest * @return ResultResponse */ @RequestMapping(value = "modifypublisher", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse modifyPublisher(@RequestBody ModifyPublisherRequest req) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); // int result = Cookie.checkAdminPermission(adminBo, Constant.ROLE_SUPER, adminId); // if(result != Cookie.RESPONSE_SUCCESS) { // rp.setResult(result); // return rp; // } if (ModifyPublisherRequest.checkParameters(req) <= 0) { return rp; } long now = System.currentTimeMillis(); Publisher obj = publisherBo.findById(Long.valueOf(req.getId())); if (obj == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } obj.setName(req.getName()); obj.setUpdateTime(now); obj.setType(req.getType()); obj.setTelephone(req.getTelephone()); publisherBo.update(obj); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * WebClient Send a Sms to Friend * @author zhangqi * @param TelephoneRequest * @return ResultResponse */ @RequestMapping(value = "tellfriend", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse tellFriend(@RequestBody TelephoneRequest req) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long userId = Cookie.checkRawCommonUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } String content = ""; Profile profile = profileBo.findById(userId); if (profile != null) { content = "" + profile.getCompanyName() + "" + profile.getUserName() + ","; } content += "?????http://app.ymm56.com"; SendSmsUtil.sendSmsChannel1(req.getTelephone(), content); // asyncProcess.sendSms(req.getTelephone(), content); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Add or Delete Shipper Member * @author zhangqi * @param ModifyCargoMemberRequest * @return ResultResponse */ @RequestMapping(value = "modifyactivitycargoer", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse modifyActivityCargo(@RequestBody ModifyCargoMemberRequest req) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); User user = userBo.findById(Long.valueOf(req.getValue())); if (user == null) { return rp; } // req.setPrivileges("00"); if (req.getType() == 1) { if (user.getAvatarAuthenticate() != Constant.USER_AUTHENTICATE_SUCCESS) { rp.setResult(Cookie.RESPONSE_AUTHENTICATE_ERROR); return rp; } try { cargoBonusListBo.setWhite(req); profileBo.updateMemberLimit(Constant.CARGO_MEMBER_AUTHENTICATE_COUNT, Constant.CARGO_MEMBER_LOCATE_COUNT, Long.valueOf(req.getValue())); AdminLog log = new AdminLog(); log.setAdminId((int) adminId); log.setCreateTime(System.currentTimeMillis()); log.setId(null); log.setInfo("upgrade to Member"); log.setTelephone(user.getTelephone()); log.setType(AdminLog.TYPE_CARGO_MEMBER); log.setUpdateTime(log.getCreateTime()); log.setUserId(user.getUserId()); adminLogBo.save(log); } catch (Exception e) { e.printStackTrace(); } } else if (req.getType() == 0) { try { cargoBonusListBo.setBlack(Long.valueOf(req.getValue())); profileBo.updateMemberLimit(0, 0, Long.valueOf(req.getValue())); AdminLog log = new AdminLog(); log.setAdminId((int) adminId); log.setCreateTime(System.currentTimeMillis()); log.setId(null); log.setInfo("dismiss MemberShip"); log.setTelephone(user.getTelephone()); log.setType(AdminLog.TYPE_CARGO_MEMBER); log.setUpdateTime(log.getCreateTime()); log.setUserId(user.getUserId()); adminLogBo.save(log); } catch (Exception e) { e.printStackTrace(); } } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author zhangqi * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getactivitycargoer", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getActivityCargoer(@RequestBody CityCountRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); int count = req.getCount(); req.setCount(count + 1); List<Object> list = cargoBonusListBo.getSupportedCargoer(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * @author zhangqi * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getmemberbytel", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetInfoResponse getMemberByTel(@RequestBody TelephoneRequest req) { GetInfoResponse rp = new GetInfoResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user == null) { return rp; } Profile profile = profileBo.findById(user.getUserId()); if (profile.getUserType() <= 1) { return rp; } if (!cargoBonusListBo.isMember(user.getUserId())) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } CargoBonusList bonusList = cargoBonusListBo.findById(user.getUserId()); BonusCargoItem item = new BonusCargoItem(user, profile, bonusList); rp.setInfo(item); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ????? * @author zhangqi * @param UpdateMemberRequest * @return ResultResponse */ @RequestMapping(value = "updatemember", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse updateMember(@RequestBody UpdateMemberRequest req) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); Profile profile = profileBo.findById(req.getId()); if (profile == null) { return rp; } if (profile.getMemberAuthenticateCount() != req.getMemberAuthenticateCount() || profile.getMemberLocateCount() != req.getMemberLocateCount()) { profileBo.updateMemberLimit(req.getMemberAuthenticateCount(), req.getMemberLocateCount(), req.getId()); } CargoBonusList list = cargoBonusListBo.findById(req.getId()); if (list != null && !req.getPrivileges().equals(list.getPrivileges())) { list.setPrivileges(req.getPrivileges()); cargoBonusListBo.update(list); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } //UnregisterOrders // /** // * Accepts a POST request with an XML message parameter // * @param message serialized Message object // * @return a string with the result of the POST // */ // @RequestMapping(value = "asksingleunregisteruser", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") // public @ResponseBody // CountResponse askSingleUnregisterUserByAdmin(@RequestBody CompleteUnregisterRequest req,//TelephoneRequest req, // HttpServletResponse response, HttpServletRequest request) { // CountResponse rp = new CountResponse(); // rp.setResult(Cookie.RESPONSE_BAD_REQUEST); // String strId = SecurityContextHolder.getContext().getAuthentication().getName(); // long pubId = Cookie.checkPublishUser(strId); // if(CompleteUnregisterRequest.checkParameters(req) <= 0){ // return rp; // } // String truckName = ""; // if(req.getName() != null && !req.getName().equals("")) { // truckName = req.getName(); // truckName = String.valueOf(truckName.charAt(0)); // } // if (req.getCargoTelephone() == null || req.getCargoTelephone().equals("")) { // UserTypeItem truckUser = profileBo.findUserTypeByTelephone(Long.valueOf(req.getTelephone())); // if (truckUser != null) { // rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); // return rp; // } // UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); // if (unregisterUser == null) { // unregisterUser = new UnregisterUser(); // unregisterUser.setCreateTime(System.currentTimeMillis()); // unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); // unregisterUser.setCallCount(0); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setType(Constant.TYPE_NORMAL); // unregisterUser.setRequestCount(0); // unregisterUser.setPushTrigger(req.getPushTrigger()); // unregisterUser.setCommonLines(req.getLines()); // unregisterUserBo.save(unregisterUser); // ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); // if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { // userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // } //// userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); //// userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); // } else { // if (unregisterUser.getType() != Constant.TYPE_DONE && unregisterUser.getType() != Constant.TYPE_DELETE) { // unregisterUser.setCallCount(0); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setType(Constant.TYPE_NORMAL); // unregisterUser.setRequestCount(0); // unregisterUser.setPushTrigger(req.getPushTrigger()); // unregisterUser.setCommonLines(req.getLines()); // unregisterUserBo.update(unregisterUser); // ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); // if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { // userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // } // } // } // rp.setResult(Cookie.RESPONSE_SUCCESS); // } else { // UserTypeItem cargoItem = profileBo.findUserTypeByTelephone(Long.valueOf(req.getCargoTelephone())); // if (cargoItem == null) { // rp.setResult(Cookie.RESPONSE_NOT_EXIST); // return rp; // } // if (cargoItem.getUserType() == Constant.USER_TYPE_TRUCKER) { // rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); // return rp; // } // int size = positionRequestBo.getRemainFocusSize(cargoItem.getUserId()); // if(size <= 0) { // rp.setResult(Cookie.RESPONSE_TOO_MUCH); // return rp; // } // UserTypeItem truckUser = profileBo.findUserTypeByTelephone(Long.valueOf(req.getTelephone())); // // User truckUser = userBo.findByTelephone(Long.valueOf(req.getTelephone())); // if(truckUser != null) { // if (truckUser.getUserType() != Constant.USER_TYPE_TRUCKER) { // rp.setResult(Cookie.RESPONSE_NOT_AVAILABLE); // return rp; // } // ResultResponse rp0 = positionRequestBo.askPosition(new ProcessPositionRequest(truckUser.getUserId()), cargoItem.getUserId(), 0, 0); // rp.setResult(rp0.getResult()); // } else { // UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); // if (unregisterUser == null) { // unregisterUser = new UnregisterUser(); // unregisterUser.setCreateTime(System.currentTimeMillis()); // unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); // unregisterUser.setCallCount(0); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setType(Constant.TYPE_NORMAL); // unregisterUser.setRequestCount(0); // unregisterUser.setPushTrigger(req.getPushTrigger()); // unregisterUser.setCommonLines(req.getLines()); // unregisterUserBo.save(unregisterUser); // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); // // //?order // ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); // if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { // List<LineItem> startList=linesResponse.getStartList(); // List<LineItem> endList=linesResponse.getEndList(); // if(startList!=null&&startList.size()>0&&endList!=null&&endList.size()>0) // { // Profile profile=profileBo.findById(cargoItem.getUserId()); // if(profile!=null) // { // int start=startList.get(0).getCity(); // int end = endList.get(0).getCity(); // UnregisterOrders order = new UnregisterOrders(); // order.setCargoUserId(profile.getUserId()); // order.setDriverUserId(unregisterUser // .getUserId()); // order.setStart(start); // order.setEnd(end); // order.setCargoName(profile.getUserName()); // order.setCargoTelephone(req.getCargoTelephone()); // order.setCargoPicture(profile.getPicture()); // order.setCompanyName(profile.getCompanyName()); // order.setCompanyAddress(profile // .getCompanyAddress()); // order.setDriverName(unregisterUser // .getUserName()); // order.setDriverTelephone(unregisterUser // .getTelephone() + ""); // order.setTruckLength(unregisterUser // .getTruckLength()); // order.setWeight(unregisterUser.getTruckLoad()); // order.setCreateTime(System.currentTimeMillis()); // order.setUpdateTime(System.currentTimeMillis()); // try { // unregisterOrdersBo.save(order); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // } // // } else { // if (unregisterUser.getType() != Constant.TYPE_DONE && unregisterUser.getType() != Constant.TYPE_DELETE) { // unregisterUser.setCallCount(0); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setType(Constant.TYPE_NORMAL); // unregisterUser.setRequestCount(0); // unregisterUser.setPushTrigger(req.getPushTrigger()); // unregisterUser.setCommonLines(req.getLines()); // unregisterUserBo.update(unregisterUser); // ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); // if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { // userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); // } // } // } //// if (unregisterUser != null && unregisterUser.getType() == Constant.TYPE_DELETE) { //// unregisterUser.setType(Constant.TYPE_NORMAL); //// unregisterUserBo.update(unregisterUser); //// } // // PositionRequest pos = positionRequestBo.findById(cargoItem.getUserId(), unregisterUser.getUserId()); // if(pos == null) { // pos = new PositionRequest(cargoItem.getUserId(), unregisterUser.getUserId(), Constant.TYPE_UNREGISTER, System.currentTimeMillis()); // pos.setUpdateTime(System.currentTimeMillis()); // pos.setNickName(req.getName()); // pos.setTruckLength(req.getTruckLength()); // pos.setTruckLoad(req.getTruckLoad()); // pos.setCity(req.getEndCity()); // positionRequestBo.save(pos); // //TODO: Update User updateTime~~~ // // profileBo.updateTime(userI) // } else { // if(pos.getType() != Constant.TYPE_UNREGISTER) { // pos.setType(Constant.TYPE_UNREGISTER); // pos.setUpdateTime(System.currentTimeMillis()); // pos.setNickName(req.getName()); // pos.setTruckLength(req.getTruckLength()); // pos.setTruckLoad(req.getTruckLoad()); // pos.setCity(req.getEndCity()); // positionRequestBo.update(pos); // } // } // // rp.setResult(Cookie.RESPONSE_SUCCESS); // if(rp.getResult() == Cookie.RESPONSE_SUCCESS) { // String name = cargoItem.getUserName(); // name = name.length() > 3 ? name.substring(0, 3) : name; // name = "" + cargoItem.getCompanyAddress() + "" + name; // CurrentStatusManager.addInviteSmsCount(1); //// asyncProcess.sendSms(req.getTelephone(), String.format(Constant.ASK_POSITION_SMS_CONTENT, truckName, name)); // } // } // if(rp.getResult() == Cookie.RESPONSE_SUCCESS) { // rp.setCount(positionRequestBo.getCargoerFriendCount(cargoItem.getUserId())); // } // } // if(rp.getResult() == Cookie.RESPONSE_SUCCESS) { // publisherBo.addInviteCount(pubId); // } //// rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); // return rp; // } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "asksingleunregisteruser", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody CountResponse askSingleUnregisterUserByAdmin(@RequestBody CompleteUnregisterRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { CountResponse rp = new CountResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long pubId = Cookie.checkPublishUser(strId); if (CompleteUnregisterRequest.checkParameters(req) <= 0) { return rp; } String truckName = ""; if (req.getName() != null && !req.getName().equals("")) { truckName = req.getName(); truckName = String.valueOf(truckName.charAt(0)); } if (req.getCargoTelephone() == null || req.getCargoTelephone().equals("")) { UserTypeItem truckUser = profileBo.findUserTypeByTelephone(Long.valueOf(req.getTelephone())); if (truckUser != null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { unregisterUser = new UnregisterUser(); unregisterUser.setCreateTime(System.currentTimeMillis()); unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); unregisterUser.setCallCount(0); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(pubId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setType(Constant.TYPE_NORMAL); unregisterUser.setRequestCount(0); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.save(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); } else { if (unregisterUser.getType() != Constant.TYPE_DONE && unregisterUser.getType() != Constant.TYPE_DELETE) { unregisterUser.setCallCount(0); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(pubId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setType(Constant.TYPE_NORMAL); unregisterUser.setRequestCount(0); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.update(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } } } rp.setResult(Cookie.RESPONSE_SUCCESS); } else { UserTypeItem cargoItem = profileBo.findUserTypeByTelephone(Long.valueOf(req.getCargoTelephone())); if (cargoItem == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } if (cargoItem.getUserType() == Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); return rp; } int size = positionRequestBo.getRemainFocusSize(cargoItem.getUserId()); if (size <= 0) { rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } UserTypeItem truckUser = profileBo.findUserTypeByTelephone(Long.valueOf(req.getTelephone())); // User truckUser = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (truckUser != null) { if (truckUser.getUserType() != Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_NOT_AVAILABLE); return rp; } ResultResponse rp0 = positionRequestBo.askPosition( new ProcessPositionRequest(truckUser.getUserId()), cargoItem.getUserId(), 0, 0); rp.setResult(rp0.getResult()); } else { UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { unregisterUser = new UnregisterUser(); unregisterUser.setCreateTime(System.currentTimeMillis()); unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); unregisterUser.setCallCount(0); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(pubId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setType(Constant.TYPE_NORMAL); unregisterUser.setRequestCount(0); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.save(unregisterUser); userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); } else { if (unregisterUser.getType() != Constant.TYPE_DONE && unregisterUser.getType() != Constant.TYPE_DELETE) { unregisterUser.setCallCount(0); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(pubId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setType(Constant.TYPE_NORMAL); unregisterUser.setRequestCount(0); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.update(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } } } // if (unregisterUser != null && unregisterUser.getType() == Constant.TYPE_DELETE) { // unregisterUser.setType(Constant.TYPE_NORMAL); // unregisterUserBo.update(unregisterUser); // } PositionRequest pos = positionRequestBo.findById(cargoItem.getUserId(), unregisterUser.getUserId()); if (pos == null) { pos = new PositionRequest(cargoItem.getUserId(), unregisterUser.getUserId(), Constant.TYPE_UNREGISTER, System.currentTimeMillis()); pos.setUpdateTime(System.currentTimeMillis()); pos.setNickName(req.getName()); pos.setTruckLength(req.getTruckLength()); pos.setTruckLoad(req.getTruckLoad()); pos.setCity(req.getEndCity()); positionRequestBo.save(pos); //TODO: Update User updateTime~~~ // profileBo.updateTime(userI) } else { if (pos.getType() != Constant.TYPE_UNREGISTER) { pos.setType(Constant.TYPE_UNREGISTER); pos.setUpdateTime(System.currentTimeMillis()); pos.setNickName(req.getName()); pos.setTruckLength(req.getTruckLength()); pos.setTruckLoad(req.getTruckLoad()); pos.setCity(req.getEndCity()); positionRequestBo.update(pos); } } rp.setResult(Cookie.RESPONSE_SUCCESS); if (rp.getResult() == Cookie.RESPONSE_SUCCESS) { String name = cargoItem.getUserName(); name = name.length() > 3 ? name.substring(0, 3) : name; name = "" + cargoItem.getCompanyAddress() + "" + name; CurrentStatusManager.addInviteSmsCount(1); // asyncProcess.sendSms(req.getTelephone(), String.format(Constant.ASK_POSITION_SMS_CONTENT, truckName, name)); } } if (rp.getResult() == Cookie.RESPONSE_SUCCESS) { rp.setCount(positionRequestBo.getCargoerFriendCount(cargoItem.getUserId())); } } if (rp.getResult() == Cookie.RESPONSE_SUCCESS) { publisherBo.addInviteCount(pubId); } // rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "completeunregisteruser", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse completeUnregisterUserByAdmin(@RequestBody CompleteUnregisterRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); if (CompleteUnregisterRequest.checkParameters(req) <= 0) { return rp; } if (Cookie.isPublishUser(strId)) { long pubId = Cookie.checkPublishUser(strId); return completeUnregisterBySales(req, pubId, Constant.TYPE_DONE); } // if (Cookie.isSalesmanUser(strId)) { // long salesId = Cookie.checkSalesmanUser(strId); // return completeUnregisterBySales(req, salesId, Constant.TYPE_UPDATE_BY_SALES); // } throw new UsernameNotFoundException("not publish user"); } private static ParseUnregisterLinesResponse parseUnregisterLines(String lines) { ParseUnregisterLinesResponse rp = new ParseUnregisterLinesResponse(); if (lines == null || lines.equals("")) { return rp; } try { List<LineItem> endList = new ArrayList<LineItem>(); Map<Integer, Integer> startMap = new HashedMap(3); Integer startLevel = 1; String[] oneLines = lines.split("#"); for (String oneLine : oneLines) { String[] cities = oneLine.split("-"); if (cities.length == 2) { Integer level = startMap.get(Integer.valueOf(cities[0])); if (level == null) { startMap.put(Integer.valueOf(cities[0]), startLevel); endList.add(new LineItem(Integer.valueOf(cities[1]), startLevel)); startLevel++; } else { endList.add(new LineItem(Integer.valueOf(cities[1]), level)); } } } rp.setEndList(endList); List<LineItem> startList = new ArrayList<LineItem>(); Iterator iterator = startMap.keySet().iterator(); while (iterator.hasNext()) { Integer city = (Integer) iterator.next(); int level = startMap.get(city); startList.add(new LineItem(city, level)); } rp.setStartList(startList); rp.setResult(Cookie.RESPONSE_SUCCESS); } catch (Exception e) { e.printStackTrace(); return rp; } return rp; } public ResultResponse completeUnregisterBySales(CompleteUnregisterRequest req, Long salesId, int type) { ResultResponse rp = new ResultResponse(); User cargoUser = null; Profile cargoProfile = null; if (req.getCargoTelephone() != null && !req.getCargoTelephone().equals("")) { cargoUser = userBo.findByTelephone(Long.valueOf(req.getCargoTelephone())); if (cargoUser == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } cargoProfile = profileBo.findById(cargoUser.getUserId()); if (cargoProfile.getUserType() == Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); return rp; } } // Locate users! // Not Send locate sms // PositionHelper.checkAvailable(req.getTelephone()); User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { if (cargoUser == null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } int size = positionRequestBo.getRemainFocusSize(cargoUser.getUserId()); if (size <= 0) { rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } return positionRequestBo.askPosition(new ProcessPositionRequest(user.getUserId()), cargoUser.getUserId(), 0, 0); } else { UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { unregisterUser = new UnregisterUser(); unregisterUser.setCreateTime(System.currentTimeMillis()); unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); unregisterUser.setCallCount(unregisterUser.getCallCount() + 1); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(salesId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setType(type); unregisterUser.setSystemType(type); unregisterUser.setRequestCount(0); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.save(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); rp.setResult(Cookie.RESPONSE_SUCCESS); } else if (unregisterUser.getType() == Constant.TYPE_DONE) { // rp.setResult(Cookie.RESPONSE_ALREADY_DONE); } else { unregisterUser.setCallCount(unregisterUser.getCallCount() + 1); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(salesId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setType(type); unregisterUser.setSystemType(type); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.clearLines(unregisterUser.getUserId()); unregisterUserBo.update(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); } rp.setResult(Cookie.RESPONSE_SUCCESS); if (cargoUser != null) { int size = positionRequestBo.getRemainFocusSize(cargoUser.getUserId()); if (size <= 0) { rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } else { if (cargoUser != null) { PositionRequest positionRequest = positionRequestBo.findById(cargoUser.getUserId(), unregisterUser.getUserId()); if (positionRequest == null) { positionRequestBo.saveOrUpdate( new PositionRequest(cargoUser.getUserId(), unregisterUser.getUserId(), Constant.TYPE_UNREGISTER, System.currentTimeMillis(), req.getName(), req.getTruckLength(), req.getTruckLoad(), req.getEndCity())); } else { positionRequest.setNickName(req.getName()); positionRequest.setTruckLength(req.getTruckLength()); positionRequest.setTruckLoad(req.getTruckLoad()); positionRequest.setType(Constant.TYPE_UNREGISTER); positionRequest.setCity(req.getEndCity()); positionRequest.setUpdateTime(System.currentTimeMillis()); positionRequestBo.update(positionRequest); } } } } if (type == Constant.TYPE_DONE) { publisherBo.addInviteCount(salesId); uploadLogBo.writeLog(salesId, unregisterUser.getUserId(), 4, System.currentTimeMillis()); } //TODO Ready to send Sms if (cargoUser == null) { asyncProcess.sendSms(unregisterUser.getTelephone().toString(), Constant.CALL_UNREGISTER_SMS_CONTENT); } else { String name = req.getName(); name = name.length() > 1 ? name.substring(0, 1) : name; String cargoName = cargoProfile.getCompanyName() + name; asyncProcess.sendSms(req.getTelephone(), String.format(Constant.ASK_POSITION_SMS_CONTENT, name, cargoName)); } } return rp; } // public ResultResponse completeUnregisterByPublisher(CompleteUnregisterRequest req, Long pubId) { // ResultResponse rp = new ResultResponse(); // User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); // if(user != null) { // rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); // return rp; // } // UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); // if(unregisterUser == null) { // unregisterUser = new UnregisterUser(); // unregisterUser.setCreateTime(System.currentTimeMillis()); // unregisterUser.setTelephone(Long.valueOf(req.getTelephone())); // unregisterUser.setCallCount(unregisterUser.getCallCount() + 1); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setType(Constant.TYPE_DONE); // unregisterUser.setRequestCount(0); // unregisterUser.setPushTrigger(req.getPushTrigger()); // unregisterUserBo.save(unregisterUser); // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); // rp.setResult(Cookie.RESPONSE_SUCCESS); // } else if (unregisterUser.getType() == Constant.TYPE_DONE) { // rp.setResult(Cookie.RESPONSE_ALREADY_DONE); // return rp; // } else { // unregisterUser.setCallCount(unregisterUser.getCallCount() + 1); // unregisterUser.setTruckLength(req.getTruckLength()); // unregisterUser.setTruckLoad(req.getTruckLoad()); // unregisterUser.setTruckType(req.getTruckType()); // unregisterUser.setPublisherId(pubId); // unregisterUser.setUpdateTime(System.currentTimeMillis()); // unregisterUser.setCompleteTime(System.currentTimeMillis()); // unregisterUser.setUserName(req.getName()); // unregisterUser.setPushTrigger(req.getPushTrigger()); // if (unregisterUser.getType() != Constant.TYPE_DELETE) {// represents INSTALLED // unregisterUser.setType(Constant.TYPE_DONE); // } // unregisterUserBo.clearLines(unregisterUser.getUserId()); // unregisterUserBo.update(unregisterUser); // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); // rp.setResult(Cookie.RESPONSE_SUCCESS); // } // //TODO Ready to send Sms //// asyncProcess.sendSms(req.getTelephone(), String.format(Constant.ASK_POSITION_SMS_CONTENT, truckName, name)); // if(rp.getResult() == Cookie.RESPONSE_SUCCESS) { // publisherBo.addInviteCount(pubId); // uploadLogBo.writeLog(pubId, unregisterUser.getUserId(), 4, System.currentTimeMillis()); // asyncProcess.sendSms(unregisterUser.getTelephone().toString(), Constant.CALL_UNREGISTER_SMS_CONTENT); // } // return rp; // } /** * Trash unregister * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "markunregister", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse markUnregister(@RequestBody TelephoneRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { CountResponse rp = new CountResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long pubId = Cookie.checkPublishUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } unregisterUser.setType(Constant.TYPE_TRASH); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setPublisherId(pubId); unregisterUserBo.update(unregisterUser); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "checkunregister", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody CountResponse checkUnregister(@RequestBody TelephoneRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { CountResponse rp = new CountResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); // long pubId = Cookie.checkPublishUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { rp.setResult(Cookie.RESPONSE_SUCCESS);//RESPONSE_NOT_EXIST return rp; } if (unregisterUser.getType() == Constant.TYPE_TRASH) { rp.setResult(Cookie.RESPONSE_NOT_AVAILABLE); return rp; } if (unregisterUser.getType() == Constant.TYPE_DONE) { rp.setResult(Cookie.RESPONSE_ALREADY_DONE); return rp; } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getunregister", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getUnregisterUser(@RequestBody TelephoneRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); // long pubId = Cookie.checkPublishUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST);//RESPONSE_NOT_EXIST return rp; } List<UserDirection> directions = userDirectionBo.findById(unregisterUser.getUserId()); List<UserOrigin> origins = userOriginBo.findById(unregisterUser.getUserId()); CompleteUnregisterRequest info = new CompleteUnregisterRequest(); info.setName(unregisterUser.getUserName()); info.setPushTrigger(unregisterUser.getPushTrigger()); info.setTelephone(unregisterUser.getTelephone().toString()); info.setTruckLength(unregisterUser.getTruckLength()); info.setTruckLoad(unregisterUser.getTruckLoad()); info.setTruckType(unregisterUser.getTruckType()); info.setStartCity(getOriginCitySet(origins)); info.setEndCity(getDirectionCitySet(directions)); info.setType(unregisterUser.getType()); info.setLines(unregisterUser.getCommonLines()); rp.setInfo(info); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } private String getOriginCitySet(List<UserOrigin> list) { if (list == null || list.isEmpty()) { return ""; } String cities = "" + list.get(0).getCity(); for (int i = 1; i < list.size(); i++) { cities += "," + list.get(i).getCity(); } return cities; } private String getDirectionCitySet(List<UserDirection> list) { if (list == null || list.isEmpty()) { return ""; } String cities = "" + list.get(0).getCity(); for (int i = 1; i < list.size(); i++) { cities += "," + list.get(i).getCity(); } return cities; } /** * Update Unregister user info by publishers * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "updateunregisteruser", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse updateUnregisterUserByAdmin(@RequestBody CompleteUnregisterRequest req, //TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long pubId = Cookie.checkPublishUser(strId); if (CompleteUnregisterRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); } else { unregisterUser.setCallCount(unregisterUser.getCallCount() + 1); unregisterUser.setTruckLength(req.getTruckLength()); unregisterUser.setTruckLoad(req.getTruckLoad()); unregisterUser.setTruckType(req.getTruckType()); unregisterUser.setPublisherId(pubId); unregisterUser.setUpdateTime(System.currentTimeMillis()); unregisterUser.setCompleteTime(System.currentTimeMillis()); unregisterUser.setUserName(req.getName()); unregisterUser.setPushTrigger(req.getPushTrigger()); unregisterUser.setType(Constant.TYPE_DONE); unregisterUser.setSystemType(Constant.TYPE_DONE); unregisterUser.setCommonLines(req.getLines()); unregisterUserBo.clearLines(unregisterUser.getUserId()); unregisterUserBo.update(unregisterUser); ParseUnregisterLinesResponse linesResponse = parseUnregisterLines(req.getLines()); if (linesResponse.getResult() == Cookie.RESPONSE_SUCCESS) { userOriginBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); userDirectionBo.replaceIntoWithLevel(unregisterUser.getUserId(), linesResponse); } // userOriginBo.replaceInto(unregisterUser.getUserId(), req.getStartCity()); // userDirectionBo.replaceInto(unregisterUser.getUserId(), req.getEndCity()); rp.setResult(Cookie.RESPONSE_SUCCESS); publisherBo.addModifyCount(pubId); } return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getordersbydate", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getordersbydate(@RequestBody BeforeAfterRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (StringUtils.isEmpty(req.getBefore()) || StringUtils.isEmpty(req.getAfter())) { rp.setList(null); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } List<Object> list = orderBo.getOrdersByDate(req.getBefore(), req.getAfter()); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getdriverlocatelist", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getdriverlocatelist(@RequestBody SearchPositionRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (StringUtils.isEmpty(req.getUserId()) || StringUtils.isEmpty(req.getBefore()) || StringUtils.isEmpty(req.getAfter())) { rp.setList(null); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } User user = userBo.findById(req.getUserId()); List<Object> list = positionLogBo.getUserLocateList(req.getUserId(), req.getBefore(), req.getAfter()); if (list == null) { list = new ArrayList<Object>(); } PositionInfo info = PositionHelper.getLocation(user.getTelephone().toString()); locateLogBo.save(new LocateLog(null, adminId, user.getTelephone(), 1, 2, System.currentTimeMillis())); if (info.getType() == Constant.SMS_LOCATE_SUCCESS) { PositionLog log = new PositionLog(null, req.getUserId(), info.getPositionTime(), info.getLon(), info.getLat(), 0); list.add(0, log); rp.setList(list); PostPositionRequest positionRequest = new PostPositionRequest(); positionRequest.setCityId(0); positionRequest.setLat(info.getLat()); positionRequest.setLon(info.getLon()); positionBo.updatePosition(positionRequest, user.getUserId()); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getaccount", method = RequestMethod.POST, produces = "application/json") public @ResponseBody GetInfoResponse getAccountBalance(@RequestBody UpdateTimeIdRequest req, HttpServletResponse response, HttpServletRequest request) { String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); GetInfoResponse rp = new GetInfoResponse(); try { Account account = accountBo.findById(req.getId()); if (account == null) { rp.setInfo(new AccountItem()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } if (req.getUpdateTime() < account.getUpdateTime()) { AccountItem info = new AccountItem(account); rp.setInfo(info); } rp.setResult(Cookie.RESPONSE_SUCCESS); } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "updateaccount", method = RequestMethod.POST, produces = "application/json") public @ResponseBody ResultResponse updateAccount(@RequestBody ChangeAccountRequest req, HttpServletResponse response, HttpServletRequest request) { String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); ResultResponse rp = new ResultResponse(); if (UpdateAccountRequest.checkParameters(req) <= 0) { return rp; } try { Account account = accountBo.findById(req.getUserId()); long now = System.currentTimeMillis(); if (account == null) { return rp; } else { // if(!req.getAccountName().equals(account.getAccountName()) || !req.getCardNumber().equals(account.getCardNumber())) { account.setBankName(""); account.setBranchName(""); account.setAccountName(req.getAccountName()); account.setCardNumber(req.getCardNumber()); account.setAlipayAccount(req.getAlipayAccount()); account.setUpdateTime(now); accountBo.update(account); // } } rp.setResult(Cookie.RESPONSE_SUCCESS); } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * get RechargeInfo list by time * @param SalerQrcRequest * @return listOf RechargeInfo */ @RequestMapping(value = "getrechargebydate", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getRechargeByDate(@RequestBody IdBeforeAfterRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (StringUtils.isEmpty(req.getBefore()) || StringUtils.isEmpty(req.getAfter())) { rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } List<Object> list = payBo.getRechargeByDate(req); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Admin Interface for Accountant * get bonus history * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getbonushistory", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getBonusHistory(@RequestBody BeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (BeforeAfterRequest.checkParameters(req) <= 0) { return rp; } int count = req.getCount(); req.setCount(count + 1); List<Object> list = accountLogBo.getBonusHistory(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Admin Interface for Accountant * get bonus history * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "disablesms", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse disableSms(@RequestBody SmsTriggerRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(); rp.setResult(Cookie.RESPONSE_SUCCESS); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (SmsTriggerRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null && user.getPushSubscribe() != req.getTrigger()) { userBo.disableSms(user.getUserId(), req.getTrigger()); } else { UnregisterUser obj = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (obj != null && obj.getPushTrigger() != req.getTrigger()) { unregisterUserBo.disableSms(obj.getUserId(), req.getTrigger()); } } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Admin Interface for Accountant * get bonus history * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getwithdrawdetails", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getWithdrawDetails(@RequestBody IdTypeBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (IdBeforeAfterRequest.checkParameters(req) <= 0) { return rp; } int count = req.getCount(); req.setCount(count + 1); List<Object> list = withDrawTaskBo.getWithdrawDetails(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Admin Interface for Accountant get bonus history * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getwithdrawdetailsfordriver", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getwithdrawdetailsfordriver(@RequestBody IdBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (IdBeforeAfterRequest.checkParameters(req) <= 0) { return rp; } int count = req.getCount(); req.setCount(count + 1); List<Object> list = withDrawTaskBo.getWithdrawDetailsForDriver(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getpublishers", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getPublishers(@RequestBody UpdateTimeRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); // int saleId = Cookie.checkSalesmanUser(strId); List<Object> list = publisherBo.getPublishers(req); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "changetelephone", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse changeTelephone(@RequestBody ChangeTelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (ChangeTelephoneRequest.checkParameters(req) <= 0) { return rp; } // int saleId = Cookie.checkSalesmanUser(strId); User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } int relult = userBo.changeTelephone(req); if (relult == Cookie.RESPONSE_SUCCESS) { AdminLog log = new AdminLog(); log.setAdminId(adminId); log.setCreateTime(System.currentTimeMillis()); log.setUpdateTime(System.currentTimeMillis()); log.setTelephone(Long.valueOf(req.getTelephone2())); log.setInfo(req.getTelephone() + ":" + req.getTelephone2()); log.setType(AdminLog.TYPE_CHANGE_TEL); log.setUserId(user.getUserId()); adminLogBo.save(log); } Client clinet = clientBo.findByTelephone(Long.valueOf(req.getTelephone())); if (clinet != null) { Client clinet1 = clientBo.findByTelephone(Long.valueOf(req.getTelephone2())); if (clinet1 == null) { clinet.setUpdateTime(System.currentTimeMillis()); clinet.setTelephone(Long.valueOf(req.getTelephone2())); } } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getcargotruckcount", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse getCargoTruckCount(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } Profile profile = profileBo.findById(user.getUserId()); if (profile.getUserType() == Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); return rp; } int size = positionRequestBo.getRemainFocusSize(user.getUserId()); if (size <= 0) { rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * Accepts a POST request with an XML message parameter * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "accountlog", method = RequestMethod.POST, produces = "application/json") public @ResponseBody GetMessagesResponse getAccountLog(@RequestBody TelephoneBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); GetMessagesResponse rp = new GetMessagesResponse(); if (BeforeAfterRequest.checkParameters(req) <= 0) { return rp; } try { User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); int count = req.getCount(); req.setCount(count + 1); List<Object> list = accountLogBo.getLog(req, user.getUserId()); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getsmslocate", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetSmsLocateResponse getSmsLocate(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { GetSmsLocateResponse rp = new GetSmsLocateResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } return PositionHelper.getSmsLocateStatus(req.getTelephone()); } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getsmslocation", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetInfoResponse getSmsLocation(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { GetInfoResponse rp = new GetInfoResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } rp.setInfo(PositionHelper.getSmsLocationForTest(req.getTelephone())); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getlocatereplynumber", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetInfoResponse getLocateReplyNumber(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { GetInfoResponse rp = new GetInfoResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } rp.setInfo(PositionHelper.getLocateReplyNumber(req.getTelephone())); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ?? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "disableposition", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse disablePosition(@RequestBody SetBlackRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_SUCCESS); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (SetBlackRequest.checkParameters(req) <= 0) { rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } AdminLog log = new AdminLog(); log.setAdminId(adminId); log.setCreateTime(System.currentTimeMillis()); log.setUpdateTime(System.currentTimeMillis()); log.setTelephone(Long.valueOf(req.getTelephone())); log.setInfo(req.getInfo()); log.setType(AdminLog.TYPE_POSITION_BLACK); User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { Position position = positionBo.findById(user.getUserId()); position.setSmsLocate(Constant.SMS_LOCATE_NEVER); log.setUserId(user.getUserId()); positionBo.update(position); } else { UnregisterUser unregisterUser = unregisterUserBo.findByTelephone(Long.valueOf(req.getTelephone())); if (unregisterUser != null) { unregisterUser.setSmsLocate(Constant.SMS_LOCATE_NEVER); log.setUserId(unregisterUser.getUserId()); unregisterUserBo.update(unregisterUser); } } adminLogBo.save(log); PositionHelper.delete(req.getTelephone()); return rp; } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "invitesmslocate", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse inviteSmsLocate(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } PositionHelper.invite(req.getTelephone()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getprofilebyidnumber", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getProfileByIdNumber(@RequestBody TokenRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (req.getToken() == null || req.getToken().equals("")) { return rp; } Certificate certificate = certificateBo.findByNumber(req.getToken()); if (certificate == null || certificate.getType() < Constant.USER_AUTHENTICATE_SUCCESS) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } User user = userBo.findById(certificate.getRealUserId()); Profile profile = profileBo.findById(certificate.getRealUserId()); Account account = accountBo.findById(certificate.getRealUserId()); if (user == null || profile == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } UserInfo info = new UserInfo(user, profile, account); rp.setInfo(info); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "userpaylog", method = RequestMethod.POST, produces = "application/json") public @ResponseBody WebPayLogResponse getPayLog(@RequestBody TelephoneBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); WebPayLogResponse rp = new WebPayLogResponse(); if (BeforeAfterRequest.checkParameters(req) <= 0) { return rp; } try { UserTypeItem item = profileBo.findUserTypeByTelephone(Long.valueOf(req.getTelephone())); if (item == null) { return rp; } Account account = accountBo.findById(item.getUserId()); if (account == null) { rp.setAccountBalance(0); } else { rp.setAccountBalance(account.getAccountBalance()); } rp.setUserName(item.getUserName()); rp.setUserType(item.getUserType()); int count = req.getCount(); req.setCount(count + 1); List<Object> list = accountLogBo.getLog(req, item.getUserId()); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * ??? * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getsmslocatebalance", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getSmsLocateBalance(@RequestBody TypeRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); Double balance = PositionHelper.queryBalance(); rp.setInfo(balance.toString()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "bindsalerqrc", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse bindsalerqrc(@RequestBody BindQrcRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (StringUtils.isEmpty(req.getTelephone()) || StringUtils.isEmpty(req.getRemark())) { return rp; } try { Long saler_id; int result = 0; // type 1: 2 3? if (req.getType() == 1) { Salesman saleman = salesmanBo.findByTelephone(Long.valueOf(req.getTelephone())); if (saleman != null) { saler_id = Long.valueOf(saleman.getId()); result = wxqrcBo.bindQrc(req.getQrcId(), saler_id, req.getType(), req.getRemark()); rp.setResult(result); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } } else if (req.getType() == 2) { User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user != null) { Profile pro = profileBo.findById(user.getUserId()); if (pro != null && Constant.USER_TYPE_CARGOER == pro.getUserType()) { saler_id = Long.valueOf(pro.getUserId()); result = wxqrcBo.bindQrc(req.getQrcId(), saler_id, req.getType(), req.getRemark()); rp.setResult(result); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } } } else if (req.getType() == 3) { PartTimer partTimer = partTimerBo.findByTelephone(Long.valueOf(req.getTelephone())); saler_id = Long.valueOf(partTimer.getId()); result = wxqrcBo.bindQrc(req.getQrcId(), saler_id, req.getType(), req.getRemark()); rp.setResult(result); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } } catch (Exception e) { rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * ?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "resetRecentCount", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse resetRecentCount(@RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (req.getId() <= 0l) { return rp; } try { WXQrc qrc = wxqrcBo.findById(req.getId()); if (null != qrc) { qrc.setRecentCount(0); qrc.setUpdateTime(System.currentTimeMillis()); qrc.setResetTime(System.currentTimeMillis()); wxqrcBo.update(qrc); rp.setResult(Cookie.RESPONSE_SUCCESS); } } catch (Exception e) { rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; } /** * Accepts a POST request with an XML message parameter * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getwxqrclist", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getwxqrclist(@RequestBody TypeBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); int count = req.getCount(); req.setCount(count + 1); List<Object> list = wxqrcBo.getQrcList(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "changeclientcity", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse changeClientCity(@RequestBody IdCityRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (IdCityRequest.checkParameters(req) <= 0) { return rp; } Client client = clientBo.findById(req.getId()); if (client == null) { return rp; } client.setCity(req.getCity()); client.setUpdateTime(System.currentTimeMillis()); clientBo.update(client); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ?? * * @param message * serialized Message object * @return a string with the result of the POST *//* @RequestMapping(value = "releaseclient", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse releaseClient(@RequestBody SalesClientIdRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication() .getName(); long adminId = Cookie.checkAdminUser(strId); if(SalesClientIdRequest.checkParameters(req) <= 0){ return rp; } salesmanClientBo.releaseClient(req.getSalesId(), req.getClientId()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; }*/ /** * ?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getclientinfo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getClientInfo(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } Client client = clientBo.findByTelephone(Long.valueOf(req.getTelephone())); if (client == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } Salesman salesman = null; if (client.getSalesId() > 0) { salesman = salesmanBo.findById(Long.valueOf(client.getSalesId())); } rp.setInfo(new ClientItem(client, salesman)); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getsalesmaninfo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getSalesmanInfo(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (TelephoneRequest.checkParameters(req) <= 0) { return rp; } Salesman salesman = salesmanBo.findByTelephone(Long.valueOf(req.getTelephone())); if (salesman == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } Salesman parent = null; if (salesman.getParentId() > 0) { parent = salesmanBo.findById(Long.valueOf(salesman.getParentId())); } rp.setInfo(new SalesmanInfo(salesman, parent)); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * 400?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "bindextension", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse bind400(@RequestBody BindExtensionRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (BindExtensionRequest.checkParameters(req) <= 0) { return rp; } ExtensionTelephone extensionTelephone = extensionTelephoneBo.findByExtension(req.getExtensionTelephone(), req.getSwitchBoard()); if (extensionTelephone != null && extensionTelephone.getType() > 0) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } if (!req.getProxyTelephone().equals("")) { ExtensionTelephone extensionTelephone2 = extensionTelephoneBo .findByExtensionByTelephone(req.getProxyTelephone()); if (extensionTelephone2 != null && extensionTelephone2.getType() > 0 && !extensionTelephone2.getProxyTelephone().equals("")) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } } extensionTelephone = new ExtensionTelephone(req.getUserId(), req.getSwitchBoard(), req.getExtensionTelephone(), System.currentTimeMillis(), System.currentTimeMillis(), req.getType(), req.getProxyTelephone()); extensionTelephoneBo.save(extensionTelephone); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * 400?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "modifyextension", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse modifyExtension(@RequestBody BindExtensionRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (BindExtensionRequest.checkParameters(req) <= 0) { return rp; } ExtensionTelephone extensionTelephone = extensionTelephoneBo.findById(req.getUserId()); if (extensionTelephone == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } ExtensionTelephone extensionTelephone2 = extensionTelephoneBo.findByExtension(req.getExtensionTelephone(), req.getSwitchBoard()); if (extensionTelephone2 != null && extensionTelephone2.getType() > 0 && !extensionTelephone.getUserId().equals(extensionTelephone2.getUserId())) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } if (!req.getProxyTelephone().equals("")) { extensionTelephone2 = extensionTelephoneBo.findByExtensionByTelephone(req.getProxyTelephone()); if (extensionTelephone2 != null && extensionTelephone2.getType() > 0 && !extensionTelephone.getUserId().equals(extensionTelephone2.getUserId()) && !extensionTelephone2.getProxyTelephone().equals("")) { rp.setResult(Cookie.RESPONSE_ALREADY_EXIST); return rp; } } extensionTelephone.setExtensionNumber(req.getExtensionTelephone()); extensionTelephone.setSwitchBoard(req.getSwitchBoard()); extensionTelephone.setUpdateTime(System.currentTimeMillis()); extensionTelephone.setType(req.getType()); extensionTelephone.setProxyTelephone(req.getProxyTelephone()); extensionTelephoneBo.update(extensionTelephone); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * 400?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "deleteextension", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse deleteExtension(@RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (IdRequest.checkParameters(req) <= 0) { return rp; } ExtensionTelephone extensionTelephone = extensionTelephoneBo.findById(req.getId()); if (extensionTelephone == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } extensionTelephone.setUpdateTime(System.currentTimeMillis()); extensionTelephone.setType(0); extensionTelephoneBo.update(extensionTelephone); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ?400?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "searchextensions", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse searchExtension(@RequestBody SearchExtensionRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); int count = req.getCount(); req.setCount(count + 1); List<Object> list = extensionTelephoneBo.search(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "initinternalusers", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody IdResultResponse initInternalUsers(@RequestBody InitInternalUserRequest req, HttpServletResponse response, HttpServletRequest request) { IdResultResponse rp = new IdResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); int result = Cookie.checkAdminPermission(adminBo, Constant.ROLE_SUPER, adminId); if (result != Cookie.RESPONSE_SUCCESS) { rp.setResult(result); return rp; } rp.setId(internalUserBo.save(req.createInternalUser())); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ???? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "searchcalluserlist", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse searchcalluserlist(@RequestBody PublishCallRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Integer publish_id = Cookie.checkPublishUser(strId); int count = req.getCount(); req.setCount(count + 1); List<Object> list = publishVisitUserBo.getaVailableCallList(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ???? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "addcall", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse addcall(@RequestBody AddCallRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Integer publish_id = Cookie.checkPublishUser(strId); if (StringUtils.isEmpty(req.getTelephone())) { return rp; } User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } Profile profile = profileBo.findById(user.getUserId()); if (profile == null || profile.getUserType() != Constant.USER_TYPE_TRUCKER) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } Publisher publisher = publisherBo.findById(Long.valueOf(publish_id)); PublishVisitUser pubUser = publishVisitUserBo.findById(user.getUserId()); if (pubUser == null) { pubUser = new PublishVisitUser(); pubUser.setUserId(user.getUserId()); pubUser.setPublishId(Long.valueOf(publish_id)); pubUser.setType(req.getType()); pubUser.setTotalCallCount(1); pubUser.setUpdateTime(System.currentTimeMillis()); publishVisitUserBo.saveOrUpdate(pubUser); } else { pubUser = new PublishVisitUser(); pubUser.setUserId(user.getUserId()); pubUser.setPublishId(Long.valueOf(publish_id)); pubUser.setType(req.getType()); pubUser.setTotalCallCount(pubUser.getTotalCallCount() + 1); pubUser.setUpdateTime(System.currentTimeMillis()); publishVisitUserBo.saveOrUpdate(pubUser); } PublishVisitLogs logs = new PublishVisitLogs(); logs.setUserId(pubUser.getUserId()); logs.setPublishId(Long.valueOf(publish_id)); logs.setUserName(profile.getUserName()); logs.setTelephone(user.getTelephone()); logs.setPublishName(publisher.getName()); logs.setComment(req.getComment()); logs.setType(req.getType()); logs.setCreateTime(System.currentTimeMillis()); publishVisitLogsBo.save(logs); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getcallstatistics", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getcallstatistics(HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkPublishUser(strId); List<Object> list = publishVisitLogsBo.getPublishCallStatisticsList(); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ?? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "searchcallloglist", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse searchcallloglist(@RequestBody TelephoneBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkPublishUser(strId); User user = userBo.findByTelephone(Long.valueOf(req.getTelephone())); if (user == null) { rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } int count = req.getCount(); req.setCount(count + 1); List<Object> list = publishVisitLogsBo.getVisitLogsByTruckTel(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "searchclerkcargo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse searchCargo(@RequestBody TelephoneRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Integer pubId = Cookie.checkAdminUser(strId); List<Object> list = cargoMessageBo.searchCargoByClerk(req); rp.setAll(1); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * ? * * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "deleteclerkcargo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultResponse deleteCargo(@RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) { ResultResponse rp = new ResultResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Integer pubId = Cookie.checkAdminUser(strId); int result = cargoMessageBo.deleteClerkCargo(req); if (CurrentStatusManager.addDeleteCount() == 100) { //SendSMS LogUtil.w(this.getClass().getSimpleName(), "Clert delete too much cargos in one day."); SendSmsUtil.sendAlertSms("13770729378,15720604556,15205158628", SendSmsUtil.ALERT_CLERK_DELETE); } /* // redis ?*/ asyncProcess.deleteCargoFromRedis(0L, req.getId()); AdminLog log = new AdminLog(); log.setAdminId(pubId); log.setCreateTime(System.currentTimeMillis()); log.setUpdateTime(System.currentTimeMillis()); log.setTelephone(0L); log.setInfo(req.getId().toString()); log.setType(AdminLog.TYPE_DELETE_CARGO); adminLogBo.save(log); rp.setResult(result); return rp; } /** * * @author shanjige * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getpolicyorder", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetPolicyOrderListResponse getActivityCargoer( @RequestBody PolicyOrderBeforeAfterRequest req) { GetPolicyOrderListResponse rp = new GetPolicyOrderListResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); int count = req.getCount(); req.setCount(count + 1); List<Object> list = policyOrderBo.getList(req); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author shanjige * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "modifyclientcity", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody BaseResponse modifyclientcity(@RequestBody TelephoneCityRequest req) { BaseResponse rp = new BaseResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (req.getCity() <= 0 || req.getTelephone() <= 0) { rp.setErrorMsg("??"); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } Client client = clientBo.findByTelephone(req.getTelephone()); if (client == null) { rp.setErrorMsg("??"); rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } client.setCity(req.getCity()); clientBo.update(client); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author shanjige * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "modifyinfo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody BaseResponse modifyinfo(@RequestBody ModifyInfoRequest req) { BaseResponse rp = new BaseResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (ModifyInfoRequest.checkParameters(req) <= 0) { rp.setErrorMsg("??"); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } String[] telephone = req.getTelephone().split("#"); if (telephone.length > 10) { rp.setErrorMsg("?10?"); rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } Profile profile = null; for (int i = 0; i < telephone.length; i++) { profile = profileBo.findByTel(Long.valueOf(telephone[i])); if (profile == null) { rp.setErrorMsg(telephone[i] + ",?,?????"); rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } } for (int i = 0; i < telephone.length; i++) { Profile profile1 = profileBo.findByTel(Long.valueOf(telephone[i])); ProfileBak profileBak = profileBakBo.findByTel(Long.valueOf(telephone[i])); if (profileBak == null) { profileBak = new ProfileBak(profile1); profileBakBo.save(profileBak); } profile1.setUserName(req.getUserName()); profile1.setPicture(""); profileBo.update(profile1); AdminLog logs = new AdminLog(null, Long.valueOf(telephone[i]), adminId, req.getInfo(), System.currentTimeMillis(), System.currentTimeMillis(), AdminLog.TYPE_MODIFY_PROFILE); adminLogBo.save(logs); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author shanjige * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "resumeinfo", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody BaseResponse resumeinfo(@RequestBody TelephoneRequest req) { BaseResponse rp = new BaseResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (req.getTelephone() == null || req.getTelephone().equals("")) { rp.setErrorMsg("??"); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } String[] telephone = req.getTelephone().split("#"); if (telephone.length > 10) { rp.setErrorMsg("?10?"); rp.setResult(Cookie.RESPONSE_TOO_MUCH); return rp; } Profile profile = null; ProfileBak profileBak = null; for (int i = 0; i < telephone.length; i++) { profileBak = profileBakBo.findByTel(Long.valueOf(telephone[i])); if (profileBak == null) { rp.setErrorMsg(telephone[i] + ",,??!"); rp.setResult(Cookie.RESPONSE_NOT_EXIST); return rp; } } AdminLog logs = null; for (int i = 0; i < telephone.length; i++) { profileBak = profileBakBo.findByTel(Long.valueOf(telephone[i])); profile = profileBo.findByTel(Long.valueOf(telephone[i])); profile.setUserName(profileBak.getUserName()); profile.setPicture(profileBak.getPicture()); profileBo.update(profile); logs = new AdminLog(null, Long.valueOf(telephone[i]), adminId, "", System.currentTimeMillis(), System.currentTimeMillis(), AdminLog.TYPE_RESUME_PROFILE); adminLogBo.save(logs); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author zhangqi * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "bunchprocesswithdraw", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody BaseResponse bunchProcessWithdraw(@RequestBody ProcessWithdrawRequest req) { BaseResponse rp = new BaseResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (ProcessWithdrawRequest.checkParameters(req) <= 0) { return rp; } if (req.getType() == Constant.WITHDRAW_TYPE_DONE) { for (IdItem item : req.getList()) { WithDraw withDraw = withDrawBo.findById(Long.valueOf((String) item.getId())); if (withDraw == null && withDraw.getType() == Constant.WITHDRAW_TYPE_DONE) { ; } else { User user = userBo.findById(withDraw.getUserId()); if (user == null) { return rp; } Profile profile = profileBo.findById(withDraw.getUserId()); rp.setResult(accountBo.doWithdraw(new IdRequest(Long.valueOf((String) item.getId())), adminId, user, profile, withDraw)); } } } else if (req.getType() == Constant.WITHDRAW_TYPE_PROCESSING) { for (IdItem item : req.getList()) { WithDraw withDraw = withDrawBo.findById(Long.valueOf((String) item.getId())); if (withDraw == null || withDraw.getType() == Constant.WITHDRAW_TYPE_DONE) { ; } else { withDraw.setType(Constant.WITHDRAW_TYPE_PROCESSING); withDraw.setUpdateTime(System.currentTimeMillis()); withDrawBo.update(withDraw); } } } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author zhangqi * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getbunchwithdrawdetails", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getBunchWithdrawDetails( @RequestBody GetBunchWithDrawDetailsRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (GetBunchWithDrawDetailsRequest.checkParameters(req) <= 0) { return rp; } List<Object> list = withDrawTaskBo.getBunchWithdrawDetails(req); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } /** * * @author andy * @param message * serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getcargos", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getcargos(@RequestBody GetCargosRequest req) { GetMessagesResponse rp = new GetMessagesResponse(); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); int adminId = Cookie.checkAdminUser(strId); if (GetCargosRequest.checkParameters(req) <= 0) { rp.setErrorMsg("??"); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); return rp; } List<Object> list = cargoMessageBo.getCargosByTel(req); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } }