Commit f893922d by zhanghj

V1.5.0--完善一键接单功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24494 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent bd415902
...@@ -3,6 +3,7 @@ package com.glsx.common.feign.client; ...@@ -3,6 +3,7 @@ package com.glsx.common.feign.client;
import java.util.List; import java.util.List;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -184,6 +185,6 @@ public interface UserClient { ...@@ -184,6 +185,6 @@ public interface UserClient {
JSONObject getUserByUsername(@RequestParam("username")String username); JSONObject getUserByUsername(@RequestParam("username")String username);
@RequestMapping(method = RequestMethod.POST, value = "/carservice/usercenter/user/autoRegisterAndLogin") @RequestMapping(method = RequestMethod.POST, value = "/carservice/usercenter/user/autoRegisterAndLogin")
JSONObject autoRegisterAndLogin(@RequestParam("orderReceivingReq")OderReceivingReq orderReceivingReq); JSONObject autoRegisterAndLogin(@RequestBody OderReceivingReq orderReceivingReq);
} }
...@@ -201,7 +201,7 @@ public class StandardOrderController extends BaseController { ...@@ -201,7 +201,7 @@ public class StandardOrderController extends BaseController {
params.put("address", address); params.put("address", address);
params.put("expectInstallTime", expectInstallTime); params.put("expectInstallTime", expectInstallTime);
params.put("carType", carType); params.put("carType", carType);
params.put("deviceGroup", deviceGroup); //params.put("deviceGroup", deviceGroup);
params.put("carColor", carColor); params.put("carColor", carColor);
params.put("remark", remark); params.put("remark", remark);
String encryptSign = getParamsMD5Sign(params); String encryptSign = getParamsMD5Sign(params);
......
...@@ -4054,6 +4054,7 @@ public class OrderServiceImpl implements IOrderService { ...@@ -4054,6 +4054,7 @@ public class OrderServiceImpl implements IOrderService {
order.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_WITHOUT_APPOINTMENT.getActiveStatus()); order.setActiveStatus(OrderActiveStatusEnum.ORDER_ACTIVE_STATUS_MECHANIC_WITHOUT_APPOINTMENT.getActiveStatus());
order.setUpdateTime(date); order.setUpdateTime(date);
order.setUpdateBy(userId); order.setUpdateBy(userId);
order.setMechanicId(userId);
confirm(order,userId); confirm(order,userId);
} }
......
...@@ -21,6 +21,7 @@ import org.apache.shiro.subject.Subject; ...@@ -21,6 +21,7 @@ import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -1339,14 +1340,15 @@ public class UserController extends BaseController { ...@@ -1339,14 +1340,15 @@ public class UserController extends BaseController {
@RequestMapping(value = "/autoRegisterAndLogin", method = { RequestMethod.POST }) @RequestMapping(value = "/autoRegisterAndLogin", method = { RequestMethod.POST })
public ResultObject autoRegisterAndLogin(HttpSession session, OderReceivingReq orderReceivingReq) { public ResultObject autoRegisterAndLogin(HttpSession session, @RequestBody OderReceivingReq orderReceivingReq) {
ResultObject result = null; ResultObject result = null;
String phoneNumber = orderReceivingReq.getPhoneNumber(); String phoneNumber = orderReceivingReq.getPhoneNumber();
SysUser sysUser = new SysUser(); SysUser sysUser = new SysUser();
sysUser.setUsername(phoneNumber); sysUser.setUsername(phoneNumber);
sysUser.setUserType(Constants.USER_TYPE_MECHANIC); sysUser.setUserType(Constants.USER_TYPE_MECHANIC);
SysUser user = sysUserService.getUserById(sysUser); SysUser user = sysUserService.getUser(sysUser);
if (user != null) { if (user != null) {
sysUserService.updateUserOpenId(orderReceivingReq, user);
result = autoLogin(session, user); result = autoLogin(session, user);
} else { } else {
SysUser u = sysUserService.registerMechanicUser(orderReceivingReq); SysUser u = sysUserService.registerMechanicUser(orderReceivingReq);
......
...@@ -376,4 +376,27 @@ public interface SysUserService { ...@@ -376,4 +376,27 @@ public interface SysUserService {
*/ */
SysUser registerMechanicUser(OderReceivingReq orderReceivingReq); SysUser registerMechanicUser(OderReceivingReq orderReceivingReq);
/**
*
* @author zhanghj
* @Title: updateUserOpenId
* @Description: TODO 更新最新绑定的小程序openid和微信openid
* @param orderReceivingReq
* @param userId
* void
* @version
*/
void updateUserOpenId(OderReceivingReq orderReceivingReq, SysUser user);
/**
*
* @author zhanghj
* @Title: getUser
* @Description: TODO 获取用户信息
* @param user
* @return
* SysUser
* @version
*/
SysUser getUser(SysUser user);
} }
...@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.util.StringUtil;
import com.glsx.common.constants.ResultObject; import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.OrderClient; import com.glsx.common.feign.client.OrderClient;
import com.glsx.common.pojo.OderReceivingReq; import com.glsx.common.pojo.OderReceivingReq;
...@@ -1060,4 +1061,44 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -1060,4 +1061,44 @@ public class SysUserServiceImpl implements SysUserService {
sysUserMapper.insertServiceMechanic(orderReceivingReq.getServiceId(), user.getId()); sysUserMapper.insertServiceMechanic(orderReceivingReq.getServiceId(), user.getId());
return user; return user;
} }
@Override
@Transactional(rollbackFor=Exception.class)
public void updateUserOpenId(OderReceivingReq orderReceivingReq, SysUser user) {
// TODO Auto-generated method stub
int userType = com.glsx.common.constants.Constants.USER_TYPE_MECHANIC;
String publicCode = orderReceivingReq.getPublicCode();
String miniCode = orderReceivingReq.getMiniCode();
String publicOpenId = getPublicOpenId(publicCode);
String miniOpenId = getMiniOpenId(miniCode, userType);
if (StringUtil.isEmpty(miniOpenId)) {
return;
}
SysUser sysUser = new SysUser();
sysUser.setUserType(userType);
sysUser.setMiniOpenId(miniOpenId);
SysUser u = sysUserMapper.get(sysUser);
/*
* 一个微信只能绑定一个类型的一个账号,置空之前绑定的微信账号
*/
if (u != null && user.getMiniOpenId().equals(miniOpenId) && !user.getId().equals(u.getId())) {
SysUser us = new SysUser();
us.setId(u.getId());
us.setMiniOpenId("");
us.setPublicOpenId("");
sysUserMapper.updateSysUser(us);
}
SysUser use = new SysUser();
use.setId(user.getId());
use.setMiniOpenId(miniOpenId);
use.setPublicOpenId(publicOpenId);
sysUserMapper.updateSysUser(sysUser);
}
@Override
public SysUser getUser(SysUser user) {
// TODO Auto-generated method stub
return sysUserMapper.get(user);
}
} }
...@@ -146,6 +146,9 @@ ...@@ -146,6 +146,9 @@
<if test="userType != null"> <if test="userType != null">
and user_type = #{userType} and user_type = #{userType}
</if> </if>
<if test="username != null">
and username = #{username}
</if>
</where> </where>
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!