Commit 05d6fd25 by zhanghj

V1.4.0--提交竞价单时,实时计算出可参与竞价的服务商列表功能代码提交 --zhanghj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@23532 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 1ce82a68
Showing 17 changed files with 327 additions and 26 deletions
......@@ -146,4 +146,30 @@ public interface UserClient {
@RequestMapping(method = RequestMethod.POST, value = "/carservice/usercenter/user/sendBiddingOrderNoBidRemindMsg")
JSONObject sendBiddingOrderNoBidRemindMsg(@RequestParam("orderList")String orderList);
/**
*
* @author zhanghj
* @Title: getServiceListByAreaCode
* @Description: TODO 获取该服务区域内的服务商列表
* @param areaCodeList
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/provider/getServiceListByAreaCode")
JSONObject getServiceListByAreaCode(@RequestParam("areaCodeList")List<Integer> areaCodeList);
/**
*
* @author zhanghj
* @Title: getUserServiceListByUserId
* @Description: TODO 通过userId获取服务商列表
* @param userList
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/provider/getUserServiceListByUserId")
JSONObject getUserServiceListByUserId(@RequestParam("userList")List<Integer> userList);
}
......@@ -276,6 +276,7 @@ public class OrderBiddingController extends BaseController {
Map<String, String> errorMap = getErrors(bindingResult);
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg(), errorMap);
}
logger.info("增加竞价单参数", sysOrder.toString());
ResultObject result = orderBiddingService.addBiddingOrder(request, sysOrder);
return result;
}
......
package com.glsx.ordercenter.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -10,7 +11,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.constants.ResultObject;
import com.glsx.common.feign.client.UserClient;
import com.glsx.common.utils.Page;
import com.glsx.common.utils.PropertiesUtil;
import com.glsx.common.utils.wehcat.TemplateData;
......@@ -28,6 +31,8 @@ public class TestController {
private TestService testService;
@Autowired
private WechatUtils wechatUtils;
@Autowired
private UserClient userClient;
@RequestMapping(value="/get", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject index(Test test){
......@@ -89,5 +94,23 @@ public class TestController {
wechatUtils.sendTemplateMessage(wechatTemplate);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
@RequestMapping(value="/getServiceListByAreaCode")
public ResultObject getServiceListByAreaCode(){
List<Integer> areaCodeList = new ArrayList<Integer>();
areaCodeList.add(110000);
areaCodeList.add(110100);
areaCodeList.add(110102);
JSONObject userObj = userClient.getServiceListByAreaCode(areaCodeList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), userObj);
}
@RequestMapping(value="/getUserServiceListByUserId")
public ResultObject getUserServiceListByUserId(){
List<Integer> userServiceList = new ArrayList<Integer>();
userServiceList.add(755);
userServiceList.add(768);
JSONObject userObj = userClient.getUserServiceListByUserId(userServiceList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), userObj);
}
}
package com.glsx.ordercenter.mapper;
import java.util.List;
import java.util.Map;
import org.springframework.data.repository.query.Param;
import org.apache.ibatis.annotations.Param;
import com.glsx.ordercenter.dto.BiddingOrderResp;
import com.glsx.ordercenter.pojo.SysOrder;
......@@ -36,5 +37,16 @@ public interface SysOrderBiddingRecordsMapper {
List<VisibleServiceProviderVo> getVisableSPbyOrderId(Integer orderId);
List<String> selectFilesByOrderId( Integer orderId, Integer fileType);
/**
*
* @author zhanghj
* @Title: insertOrderBiddingRecords
* @Description: TODO 批量插入可竞价服务商列表
* @param visiableService
* void
*
*/
void insertOrderBiddingRecords(@Param("visiableServiceList")List<Map<String, Object>> visiableServiceList);
}
\ No newline at end of file
......@@ -32,7 +32,7 @@ public interface SysOrderLabelMapper {
* int
*
*/
int addLabelList(@Param("orderId")Integer orderId, @Param("labelArray")String[] labelArray);
int addLabelList(@Param("orderId")Integer orderId, @Param("labels")List<String> labels);
List<String> selectByOrderId(@Param("orderId")Integer orderId);
}
......
......@@ -363,7 +363,6 @@ public class SysOrder {
/**
* 服务商报价
*/
@NotBlank(message="{param.not.null}", groups={GroupC.class})
private BigDecimal price;
......
......@@ -6,8 +6,11 @@ package com.glsx.ordercenter.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.regex.Pattern;
......@@ -23,6 +26,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.glsx.common.constants.ResultObject;
......@@ -53,6 +57,7 @@ import com.glsx.ordercenter.mapper.SysOrderStatusMapper;
import com.glsx.ordercenter.mapper.SysOrganizationMapper;
import com.glsx.ordercenter.mapper.SysUserMapper;
import com.glsx.ordercenter.mapper.biddingorder.SysBiddingOrderMapper;
import com.glsx.ordercenter.pojo.SysArea;
import com.glsx.ordercenter.pojo.SysOrder;
import com.glsx.ordercenter.pojo.SysOrderBiddingRecords;
import com.glsx.ordercenter.pojo.SysOrderBiddingRecordsExample;
......@@ -63,6 +68,7 @@ import com.glsx.ordercenter.pojo.SysOrganization;
import com.glsx.ordercenter.pojo.VisibleServiceProviderVo;
import com.glsx.ordercenter.pojo.user.SysMerchantExample;
import com.glsx.ordercenter.pojo.user.SysUser;
import com.glsx.ordercenter.service.IAreaService;
import com.glsx.ordercenter.service.IOrderBiddingService;
import com.glsx.ordercenter.service.IOrderService;
......@@ -118,6 +124,8 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
@Autowired
private SysOrderStatusMapper orderStatusDao;
@Autowired
private IAreaService areaService;
private JSONObject getUserInfo(Integer userId) {
JSONObject obj = userClient.getUserById(userId);
......@@ -544,17 +552,98 @@ public class OrderBiddingServiceImpl implements IOrderBiddingService {
sysOrderFileDao.addOrderFileList(fileList);
List<String> labels = sysOrder.getLabels();
String[] labelArray = new String[0];
if (!labels.isEmpty()) {
labelArray = (String[]) labels.toArray();
}
sysOrderLabelDao.addLabelList(orderId, labelArray);
sysOrderLabelDao.addLabelList(orderId, labels);
/*
* 计算可见服务商列表
*/
computeVisibleService(serviceTypeArray, sysOrder);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg());
}
/**
*
* @author zhanghj
* @Title: computeVisibleService
* @Description: TODO 计算匹配是服务商列表
* @param serviceTypeArray
* @param sysOrder
* void
*
*/
private void computeVisibleService(String[] serviceTypeArray,
SysOrder sysOrder) {
// TODO Auto-generated method stub
Integer district = sysOrder.getDistrict();
Integer orderId = sysOrder.getId();
/*
* 使用地址匹配服务商的服务范围
*/
SysArea area = areaService.getAllChargeItems(district);
List<Integer> areaCodeList = new ArrayList<Integer>();
areaCodeList.add(district);
if (area != null) {
Integer provinceCode = area.getId();
areaCodeList.add(provinceCode);
List<SysArea> children = area.getChildren();
if (children != null && children.size() >0) {
Integer cityCode = children.get(0).getId();
areaCodeList.add(cityCode);
}
}
JSONObject userObj = userClient.getServiceListByAreaCode(areaCodeList);
JSONArray userArray = new JSONArray();
List<Integer> userList = new ArrayList<Integer>();
if (userObj != null && userObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
userArray = userObj.getJSONArray("data");
}
if (userArray != null && userArray.size() > 0) {
userList = JSONObject.parseArray(userArray.toJSONString(), Integer.class);
}
JSONObject userServiceObj = userClient.getUserServiceListByUserId(userList);
JSONArray userServiceArray = new JSONArray();
List<Integer> userServiceList = new ArrayList<Integer>();
List<String> orderServiceTypeList = new ArrayList<String>();
if (userServiceObj != null && userServiceObj.getIntValue("code") == ResultCodeEnum.SUCCESS.getCode()) {
userServiceArray = userServiceObj.getJSONArray("data");
if (userServiceArray != null && userServiceArray.size() >0) {
orderServiceTypeList = JSONObject.parseArray(userServiceArray.toJSONString(), String.class);
}
}
if (userServiceArray != null && userServiceArray.size() > 0) {
List<Map<String, Object>> visiableServiceList = new ArrayList<Map<String, Object>>();
for (int i=0;i<userServiceArray.size();i++) {
JSONObject user = userServiceArray.getJSONObject(i);
Integer userId = user.getInteger("userId");
String serviceKey = user.getString("serviceKey");
String publicOpenId = user.getString("publicOpenId");
if (!org.springframework.util.StringUtils.isEmpty(serviceKey)) {
List<String> userServiceTypeArray = Arrays.asList(serviceKey.split(","));
if (orderServiceTypeList.retainAll(userServiceTypeArray)) {
Map<String, Object> map =new HashMap<String, Object>();
map.put("userId", userId);
map.put("publicOpenId", publicOpenId);
map.put("orderId", orderId);
map.put("createTime", sysOrder.getCreateTime());
visiableServiceList.add(map);
}
}
}
logger.info("可竞价服务商列表", visiableServiceList.toString());
/*
* 批量插入可竞价服务商列表
*/
if (visiableServiceList.size() > 0) {
sysOrderBiddingRecordsMapper.insertOrderBiddingRecords(visiableServiceList);
}
}
}
/**
*
*/
@Override
public ResultObject installStart(Integer orderId, String files, String installRemark) {
......
......@@ -249,4 +249,16 @@
from sys_order_file
where order_id = #{orderId} and file_type = #{fileType}
</select>
<insert id="insertOrderBiddingRecords" parameterType="list" useGeneratedKeys="true"
keyProperty="id">
insert into sys_order_bidding_records
(service_id, order_id, create_time, update_time)
values
<foreach item="item" index="index" collection="visiableServiceList"
separator=",">
(#{item.userId}, #{item.orderId}, #{item.createTime}, #{item.createTime})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -70,7 +70,7 @@
<insert id="addLabelList" keyProperty="id" useGeneratedKeys="true">
insert into sys_order_label (order_id, label)
values
<foreach item="item" collection="labelArray" separator=",">
<foreach item="item" collection="labels" separator=",">
(#{orderId}, #{item})
</foreach>
</insert>
......
......@@ -130,6 +130,8 @@ public class ShiroConfig {
filterChainDefinitionMap.put("/user/getMechanicSP", "anon");
//微信登陆
filterChainDefinitionMap.put("/user/wxLogin", "anon");
//获取在线管理员列表
filterChainDefinitionMap.put("/user/getOnlineManagerList", "anon");
//退出
// filterChainDefinitionMap.put("/user/logout", "logout");
// filterChainDefinitionMap.put("/**", "authc");
......
package com.glsx.usercenter.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.groups.Default;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.common.annotation.Log;
......@@ -10,20 +25,10 @@ import com.glsx.usercenter.constants.ResultCodeEnum;
import com.glsx.usercenter.pojo.sp.ProviderQueryVo;
import com.glsx.usercenter.pojo.sp.ProviderVo;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysUserServices;
import com.glsx.usercenter.service.ISysProviderService;
import com.glsx.usercenter.utils.AccountValidatorUtil;
import com.glsx.usercenter.utils.ShiroUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.groups.Default;
import java.util.HashMap;
import java.util.Map;
/**
* @author jin
......@@ -109,5 +114,36 @@ public class ProviderController extends BaseController {
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), provier);
}
/**
*
* @author zhanghj
* @Title: getServiceListByAreaCode
* @Description: TODO
* @param areaCodeList
* @return
* ResultObject
*
*/
@GetMapping("/getServiceListByAreaCode")
public ResultObject getServiceListByAreaCode(@RequestParam("areaCodeList")List<Integer> areaCodeList) {
List<Integer> userList = providerService.getServiceListByAreaCode(areaCodeList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), userList);
}
/**
*
* @author zhanghj
* @Title: getUserServiceListByUserId
* @Description: TODO
* @param userList
* @return
* ResultObject
*
*/
@GetMapping("/getUserServiceListByUserId")
public ResultObject getUserServiceListByUserId(@RequestParam("userList")List<Integer> userList) {
List<SysUserServices> userServiceList = providerService.getUserServiceListByUserId(userList);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), userServiceList);
}
}
......@@ -3,9 +3,12 @@ package com.glsx.usercenter.mapper.sp;
import com.glsx.usercenter.pojo.sp.ProviderQueryVo;
import com.glsx.usercenter.pojo.sp.ProviderVo;
import com.glsx.usercenter.pojo.user.SysUserServices;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysServiceProviderMapper {
/**
* 查询服务商列表
......@@ -22,4 +25,28 @@ public interface SysServiceProviderMapper {
* @return
*/
ProviderVo getProvider(Integer providerId);
/**
*
* @author zhanghj
* @Title: getServiceListByAreaCode
* @Description: TODO 获取该服务区域内的服务商列表
* @param areaCodeList
* @return
* List<Integer>
*
*/
List<Integer> getServiceListByAreaCode(@Param("areaCodeList")List<Integer> areaCodeList);
/**
*
* @author zhanghj
* @Title: getUserServiceListByUserId
* @Description: TODO 查询服务商列表
* @param userList
* @return
* List<SysUserServices>
*
*/
List<SysUserServices> getUserServiceListByUserId(@Param("userList")List<Integer> userList);
}
\ No newline at end of file
......@@ -19,6 +19,11 @@ public class SysUserServices {
* 商户资源匹配状态(sys_user_status_unbound_service:未绑定服务商;sys_user_status_unbound_mechanic:已绑定服务商未绑定技工;sys_user_status_bound:两者都绑定)
*/
private String merchantStatus;
/**
* 公众号id
*/
private String publicOpenId;
public Integer getId() {
return id;
......@@ -59,4 +64,13 @@ public class SysUserServices {
public void setMerchantStatus(String merchantStatus) {
this.merchantStatus = merchantStatus;
}
public String getPublicOpenId() {
return publicOpenId;
}
public void setPublicOpenId(String publicOpenId) {
this.publicOpenId = publicOpenId;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.glsx.common.constants.ResultObject;
import com.glsx.usercenter.pojo.sp.ProviderQueryVo;
import com.glsx.usercenter.pojo.sp.ProviderVo;
import com.glsx.usercenter.pojo.user.SysManager;
import com.glsx.usercenter.pojo.user.SysUserServices;
import java.util.List;
......@@ -39,4 +40,18 @@ public interface ISysProviderService {
* @return
*/
ResultObject save(SysManager sysManager);
/**
*
* @author zhanghj
* @Title: getServiceListByAreaCode
* @Description: TODO 获取该服务区域内的服务商列表
* @param areaCodeList
* @return
* List<Integer>
*
*/
List<Integer> getServiceListByAreaCode(List<Integer> areaCodeList);
List<SysUserServices> getUserServiceListByUserId(List<Integer> userList);
}
......@@ -24,6 +24,7 @@ import com.glsx.usercenter.service.ISysProviderService;
import com.glsx.usercenter.service.SysUserService;
import com.glsx.usercenter.utils.QRCodeUtil;
import com.glsx.usercenter.utils.ShiroUtil;
import org.apache.commons.lang3.StringUtils;
import org.crazycake.shiro.RedisSessionDAO;
import org.slf4j.Logger;
......@@ -34,6 +35,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.ByteArrayOutputStream;
import java.util.*;
......@@ -263,4 +265,19 @@ public class ISysProviderServiceImpl implements ISysProviderService {
provider.setArea(areaService.getAllChargeItems(provider.getAddressCode()));
}
}
@Override
public List<Integer> getServiceListByAreaCode(List<Integer> areaCodeList) {
// TODO Auto-generated method stub
List<Integer> userList = providerMapper.getServiceListByAreaCode(areaCodeList);
return userList;
}
@Override
public List<SysUserServices> getUserServiceListByUserId(
List<Integer> userList) {
// TODO Auto-generated method stub
List<SysUserServices> userServiceList = providerMapper.getUserServiceListByUserId(userList);
return userServiceList;
}
}
......@@ -116,4 +116,31 @@
ORDER BY u.create_time DESC
</select>
<select id="getServiceListByAreaCode" parameterType="java.util.List" resultType="integer">
select
DISTINCT(service_provider_id)
from sys_service_area
where
area_id IN
<foreach item="item" index="index" collection="areaCodeList"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getUserServiceListByUserId" parameterType="java.util.List" resultType="com.glsx.usercenter.pojo.user.SysUserServices">
select
sus.id, sus.user_id as userId, GROUP_CONCAT(sus.service_key SEPARATOR ',') as serviceKey,
su.public_openId as publicOpenId
from
sys_user_services sus
LEFT JOIN sys_user su ON sus.user_id = su.id
WHERE
sus.user_id IN
<foreach item="item" index="index" collection="userList"
open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY sus.user_id
</select>
</mapper>
\ No newline at end of file
......@@ -42,17 +42,18 @@ CREATE TABLE `sys_order_file` (
CREATE TABLE `sys_order_bidding_records` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`merchant_id` int(11) NOT NULL COMMENT '服务商ID',
`service_id` int(11) NOT NULL COMMENT '服务商ID',
`order_id` int(11) NOT NULL COMMENT '订单ID',
`price` decimal(10,2) NOT NULL COMMENT '服务商出价',
`is_bidding` int(2) NOT NULL DEFAULT '0' COMMENT '中标状态,0待选标,1中标,,2未中标',
`price` decimal(10,2) DEFAULT '0.00' COMMENT '服务商出价',
`is_bidding` int(2) NOT NULL DEFAULT '0' COMMENT '中标状态,0未报价,1中标,,2已报价,3未中标',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL COMMENT '更新时间',
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`) USING BTREE,
KEY `idx_sp_id` (`merchant_id`) USING BTREE COMMENT '服务商ID',
KEY `idx_sp_id` (`service_id`) USING BTREE COMMENT '服务商ID',
KEY `idx_order_id` (`order_id`) USING BTREE COMMENT '订单ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='(竞价单)竞价记录表';
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='(竞价单)竞价记录表';
-- add by jin 20190813 START
ALTER TABLE `sys_manager`
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!