Commit 0c868a52 by huluobin

标签改成map

parent beb971df
......@@ -311,11 +311,11 @@ public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> impleme
private void joinCouponCustomerRelevanceMapper(List<CouponCustomerRelevance> couponCustomerRelevanceList) {
List<Integer> ids = couponCustomerRelevanceList.stream().map(CouponCustomerRelevance::getId).collect(Collectors.toList());
List<Integer> ids = couponCustomerRelevanceList.stream().map(CouponCustomerRelevance::getCouponId).collect(Collectors.toList());
List<Coupon> couponList = couponMapper.selectList(
new LambdaQueryWrapper<Coupon>().in(Coupon::getId, couponCustomerRelevanceList, ids)
new LambdaQueryWrapper<Coupon>().in(Coupon::getId, ids)
);
Map<Integer, List<Coupon>> couponMap = couponList.stream().collect(Collectors.groupingBy(Coupon::getId));
couponCustomerRelevanceList.forEach(couponCustomerRelevance -> couponCustomerRelevance.setCoupon(couponMap.get(couponCustomerRelevance.getId()).stream().findAny().orElse(null)));
couponCustomerRelevanceList.forEach(couponCustomerRelevance -> couponCustomerRelevance.setCoupon(couponMap.get(couponCustomerRelevance.getCouponId()).stream().findAny().orElse(null)));
}
}
......@@ -11,7 +11,6 @@ import com.gogirl.shared.order.serve.command.schedule.SubmitScheduleCommand;
import com.gogirl.shared.order.serve.command.schedule.UpdateScheduleCommand;
import com.gogirl.shared.order.serve.query.dto.IdleTimeDTO;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManagePageQuery;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManageQuery;
import java.text.ParseException;
import java.util.List;
......@@ -114,7 +113,8 @@ public interface ScheduleManageService extends IService<ScheduleManage> {
*/
List<Map<String, Object>> queryReservableTime(String startDate, Integer lengthTime, Integer departmentId, Integer orderId, Boolean needRemoveOldServe);
ScheduleManage queryScheduleManage(ScheduleManageQuery qry);
ScheduleManage queryScheduleManage(Integer id);
IPage<ScheduleManage> queryPageScheduleManage(ScheduleManagePageQuery qry);
}
......@@ -23,6 +23,7 @@ import com.gogirl.domain.store.store.StoreClassesTechnician;
import com.gogirl.domain.store.store.StoreManage;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.user.Customer;
import com.gogirl.dto.IdleTimeProgramQuery;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.CloneUtil;
import com.gogirl.infrastructure.common.util.ListUtil;
......@@ -40,12 +41,10 @@ import com.gogirl.infrastructure.mapper.product.serve.TechnicianServeMapper;
import com.gogirl.infrastructure.mapper.store.StoreManageMapper;
import com.gogirl.infrastructure.mapper.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.mapper.store.TakeLeaveEventMapper;
import com.gogirl.dto.IdleTimeProgramQuery;
import com.gogirl.shared.order.serve.command.schedule.*;
import com.gogirl.shared.order.serve.query.dto.IdleTimeDTO;
import com.gogirl.shared.order.serve.query.qry.*;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManagePageQuery;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManageQuery;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
......@@ -885,7 +884,6 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
ScheduleManageCommand scheduleManageDTO = cmd.getScheduleManageDTO();
cmd.getScheduleManageDTO().getScheduleServeDTOList().forEach(scheduleServeCommand -> {
if (scheduleServeCommand.getMainServeId() == null) {
......@@ -1153,8 +1151,17 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
}
@Override
public ScheduleManage queryScheduleManage(ScheduleManageQuery qry) {
return null;
public ScheduleManage queryScheduleManage(Integer id) {
ScheduleManage scheduleManage = scheduleManageMapper.selectById(id);
List<ScheduleServe> scheduleServeList = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, id));
Set<ScheduleServe> set = new TreeSet<>(Comparator.comparing(o -> o.getSchId() + ";" + o.getServeId()));
if (ListUtil.isNotEmpty(scheduleServeList)) {
set.addAll(scheduleServeList);
}
scheduleManage.setListScheduleServer(set);
return scheduleManage;
}
@Override
......
......@@ -17,4 +17,20 @@ public interface StoreTechnicianService extends IService<StoreTechnician> {
void updateTechnicianByAuthorityId(StoreTechnician item);
List<StoreTechnician> queryDayTechnicianClasses(Integer departmentId, Date day);
/**
* 美甲师登陆
*
* @param code
*/
String login(String code);
/**
* 获取美甲师信息(不同店铺对应不同的美甲师)
* @param token
* @return
*/
List<StoreTechnician> getTechnicianInfo(String token);
StoreTechnician choseStoreByOrderId(String token, Integer orderId);
}
......@@ -2,18 +2,34 @@ package com.gogirl.application.store.store.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.order.serve.OrderManageService;
import com.gogirl.application.store.store.StoreTechnicianService;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.application.xcx.WechatService;
import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.store.StoreTechnicianMapper;
import com.gogirl.infrastructure.mapper.store.UserTechnicianMapper;
import com.gogirl.infrastructure.mapper.xcx.GogirlTokenMapper;
import com.gogirl.shared.member.wx.query.dto.Code2SessionResult;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
@AllArgsConstructor
@Transactional
public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMapper, StoreTechnician> implements StoreTechnicianService {
private final UserTechnicianMapper StoreTechnicianMapper;
......@@ -38,4 +54,124 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe
return StoreTechnicianMapper.queryDayTechnicianClasses(departmentId, day);
}
private final WechatService wechatService;
private final GogirlTokenMapper gogirlTokenMapper;
@Override
public String login(String code) {
Code2SessionResult responseResult = wechatService.getTechnicianOpenidByCode(code);
if (responseResult.getErrcode() != null) {
throw new RRException(responseResult.getErrmsg());
}
String openid = responseResult.getOpenid();
//生成token
String token = new BigInteger((int) (Math.random() * 1000) + new SimpleDateFormat("ddHHmmss").format(new Date()), 10).toString(16);
StoreTechnician param = new StoreTechnician();
param.setOpenid(openid);
List<StoreTechnician> list = this.listTechnicianForPage(param);
GogirlToken gogirlToken = new GogirlToken();
if (ListUtil.isNotEmpty(list) && list.size() == 1) {
gogirlToken.setCustomerId(list.get(0).getId());
gogirlTokenMapper.updateById(gogirlToken);
}
//美甲师token
gogirlToken.setSysId(2);
gogirlToken.setOpenid(openid);
// 返回美甲师信息及token
gogirlToken.setCreateTime(new Date());
gogirlToken.setUpdateTime(new Date());
gogirlToken.setToken(token);
gogirlTokenMapper.insert(gogirlToken);
return token;
}
private final GogirlTokenService gogirlTokenService;
@Override
public List<StoreTechnician> getTechnicianInfo(String token) {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken_t(token);
//获取美甲师信息
if (gogirlToken.getCustomerId() != null) {
StoreTechnician storeTechnician = this.getTechnicianManageForDetail(gogirlToken.getCustomerId());
List<StoreTechnician> list = Lists.newArrayList(storeTechnician);
return list;
}
//token customerId为空
else {
StoreTechnician param = new StoreTechnician();
param.setOpenid(gogirlToken.getOpenid());
List<StoreTechnician> list = this.listTechnicianForPage(param);
//选择门店
if (ListUtil.isNotEmpty(list) && list.size() > 1) {
log.info("美甲师选择门店");
}
//set customerId
else if (ListUtil.isNotEmpty(list) && list.size() == 1) {
gogirlToken.setCustomerId(list.get(0).getId());
gogirlTokenMapper.updateById(gogirlToken);
log.info("存在美甲师, setCustomerId (ssa.id)");
}
//list is empty
else {
log.info("绑定手机号");
}
return list;
}
}
private final OrderManageService orderManageService;
@Override
public StoreTechnician choseStoreByOrderId(String token, Integer orderId) {
GogirlToken gt = gogirlTokenService.getTokenByToken(token);
if (token == null || token.isEmpty()) {
throw new RRException("入参token为空");
}
if (orderId == null) {
throw new RRException("入参orderId为空");
}
if (gt == null) {
throw new RRException("token过期");
}
OrderManage orderManage = orderManageService.queryOrder(orderId);
if (orderManage == null) {
throw new RRException("找不到订单");
}
if (orderManage.getDepartmentId() == null) {
throw new RRException("订单无店铺");
}
List<StoreTechnician> listStoreTechnician = this.getTechnicianManageByOpenid(gt.getOpenid());
if (listStoreTechnician == null) {
throw new RRException("找不到该美甲师账号");
}
for (StoreTechnician storeTechnician : listStoreTechnician) {
if (storeTechnician.getDepartmentId().equals(orderManage.getDepartmentId())) {
GogirlToken gogirlToken = new GogirlToken();
gogirlToken.setId(gt.getId());
gogirlToken.setCustomerId(storeTechnician.getId());
gogirlTokenService.updateByPrimaryKeySelective(gogirlToken);
return storeTechnician;
}
}
return null;
}
}
......@@ -3,6 +3,8 @@ package com.gogirl.application.user.customer;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gogirl.domain.user.Customer;
import java.security.InvalidAlgorithmParameterException;
public interface CustomerService extends IService<Customer> {
......@@ -21,4 +23,53 @@ public interface CustomerService extends IService<Customer> {
* @return customer
*/
Customer selectByCustomerId(Integer scheduledUser);
/**
* 用户登陆
*
* @param code 微信小程序code
* @return 服务器登陆状态token
*/
String login(String code);
/**
* 授权地址信息
*
* @param customerId
* @param province
* @param city
* @param area
* @param street
*/
void bindAddressInfo(Integer customerId, String province, String city, String area, String street);
/**
* 授权信息
*
* @param token
* @param encryptedData
* @param iv
* @return
*/
Customer authorized1(String token, String encryptedData, String iv) throws InvalidAlgorithmParameterException;
/**
* 授权手机号码
*
* @param token
* @param encryptedData
* @param iv
* @return
*/
Customer authorizedPhone(String token, String encryptedData, String iv) throws InvalidAlgorithmParameterException;
/**
* 根据token获取customer
* @param token
* @return
*/
Customer getUserInfo(String token) throws Exception;
}
package com.gogirl.application.user.customer.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.user.customer.CustomerService;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.application.xcx.QRCodeService;
import com.gogirl.application.xcx.WechatService;
import com.gogirl.domain.order.serve.ScheduleManage;
import com.gogirl.domain.user.Customer;
import com.gogirl.domain.user.CustomerBalance;
import com.gogirl.domain.user.CustomerDetail;
import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.mapper.order.serve.ScheduleManageMapper;
import com.gogirl.infrastructure.mapper.user.CustomerBalanceMapper;
import com.gogirl.infrastructure.mapper.user.CustomerDetailMapper;
import com.gogirl.infrastructure.mapper.user.CustomerMapper;
import com.gogirl.infrastructure.mapper.xcx.GogirlTokenMapper;
import com.gogirl.infrastructure.util.WXCore;
import com.gogirl.infrastructure.util.lock.Openid1Lock;
import com.gogirl.shared.member.wx.query.dto.Code2SessionResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import java.security.InvalidAlgorithmParameterException;
import java.util.Date;
import java.util.List;
@Service
@AllArgsConstructor
@Slf4j
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements CustomerService {
private final CustomerMapper customerMapper;
private final WechatService wechatService;
private final GogirlTokenMapper gogirlTokenMapper;
@Override
public Customer selectByPhone(String phone) {
......@@ -24,4 +49,251 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
public Customer selectByCustomerId(Integer scheduledUser) {
return customerMapper.selectById(scheduledUser);
}
@Override
public String login(String code) {
log.info("调用login,授权用户信息到程序 code:{}", code);
Openid1Lock lock = Openid1Lock.getInsatance();
Code2SessionResult result = wechatService.getCustomerOpenidByCode(code);
String token = IdWorker.getIdStr();
//创建token
GogirlToken gogirlToken = GogirlToken.builder()
.code(code)
.sysId(1)
.openid(result.getOpenid())
.sessionKey(result.getSessionKey())
.createTime(new Date())
.updateTime(new Date())
.unionid(result.getUnionid())
.token(token)
.build();
String openid = gogirlToken.getOpenid();
try {
lock.lock(openid1GetInt(openid));
//变量为当前登陆用户
Customer customer;
customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, openid));
//不存在小程序用户
if (customer == null) {
//token unionid 不为空
if (StringUtils.isNotEmpty(result.getUnionid())) {
customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getUnionid, result.getUnionid()));
//不存在公众号用户
if (customer == null) {
customer = Customer.builder()
.customerSource(4)
//小程序openid
.openid1(openid)
.orderTimes(0)
.registerTime(new Date())
.scheduledTimes(0)
//微信授权
.source(3)
//状态 正常
.state("1")
.updateTime(new Date())
.build();
customerMapper.insert(customer);
}
// 存在公众号用户
else {
customer.setOpenid1(openid);
customerMapper.updateById(customer);
}
}
//union id为空
else {
customer = Customer.builder()
.customerSource(4)
//小程序openid
.openid1(openid)
.orderTimes(0)
.registerTime(new Date())
.scheduledTimes(0)
//微信授权
.source(3)
//状态 正常
.state("1")
.updateTime(new Date())
.build();
customerMapper.insert(customer);
}
}
gogirlToken.setCustomerId(customer.getId());
gogirlTokenMapper.insert(gogirlToken);
} finally {
lock.unlock(openid1GetInt(openid));
}
return token;
}
@Override
public void bindAddressInfo(Integer customerId, String province, String city, String area, String street) {
Customer customer = customerMapper.selectById(customerId);
customer.setProvince(province);
customer.setCity(city);
customer.setArea(area);
customer.setStreet(street);
customerMapper.updateById(customer);
}
private final GogirlTokenService gogirlTokenService;
@Override
public Customer authorized1(String token, String encryptedData, String iv) throws InvalidAlgorithmParameterException {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
JSONObject data = WXCore.decrypt(encryptedData, gogirlToken.getSessionKey(), iv);
String unionid = (String) data.get("unionId");
String openid = (String) data.get("openId");
Integer gender = (Integer) data.get("gender");
String avatarUrl = (String) data.get("avatarUrl");
String city = (String) data.get("city");
String country = (String) data.get("country");
String province = (String) data.get("province");
String nickName = filterEmoji((String) data.get("nickName"));
Customer customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, openid));
customer.setSex(gender == 1 ? "男" : gender == 2 ? "女" : "未知");
customer.setHeadimgurl(avatarUrl);
customer.setNickname(nickName);
customer.setProvince(province);
customer.setCountry(country);
customer.setCity(city);
customer.setUnionid(unionid);
customerMapper.updateById(customer);
return customer;
}
private final ScheduleManageMapper scheduleManageMapper;
@Override
public Customer authorizedPhone(String token, String encryptedData, String iv) throws InvalidAlgorithmParameterException {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
JSONObject data = WXCore.decrypt(encryptedData, gogirlToken.getSessionKey(), iv);
String phone = (String) data.get("purePhoneNumber");
gogirlToken.setPhone(phone);
gogirlTokenMapper.updateById(gogirlToken);
Customer customer = customerMapper.selectById(gogirlToken.getCustomerId());
Customer phoneCustomer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getPhone, phone));
//如果存在手机号
if (phoneCustomer != null) {
phoneCustomer.setSex(customer.getSex());
phoneCustomer.setHeadimgurl(customer.getHeadimgurl());
phoneCustomer.setNickname(customer.getNickname());
phoneCustomer.setProvince(customer.getProvince());
phoneCustomer.setCountry(customer.getCountry());
phoneCustomer.setCity(customer.getCity());
phoneCustomer.setUnionid(customer.getUnionid());
phoneCustomer.setCustomerSource(customer.getCustomerSource());
phoneCustomer.setOpenid1(customer.getOpenid1());
phoneCustomer.setRegisterTime(customer.getRegisterTime());
phoneCustomer.setScheduledTimes(customer.getScheduledTimes());
phoneCustomer.setSource(customer.getSource());
phoneCustomer.setState(customer.getState());
phoneCustomer.setUpdateTime(new Date());
customerMapper.updateById(phoneCustomer);
customerMapper.deleteById(customer);
List<ScheduleManage> scheduleManageList = scheduleManageMapper.selectList(new LambdaQueryWrapper<ScheduleManage>()
.eq(ScheduleManage::getTelephone, phone));
if (ListUtil.isNotEmpty(scheduleManageList)) {
scheduleManageList.forEach(scheduleManage -> {
scheduleManage.setTelephone(phone);
scheduleManageMapper.updateById(scheduleManage);
});
}
//清除token
gogirlTokenMapper.delete(new LambdaQueryWrapper<GogirlToken>().eq(GogirlToken::getCustomerId, customer.getId()));
return phoneCustomer;
}
//不存在手机号
else {
customer.setPhone(phone);
customerMapper.updateById(customer);
return customer;
}
}
private final CustomerDetailMapper customerDetailMapper;
private final CustomerBalanceMapper customerBalanceMapper;
private final QRCodeService qrCodeService;
@Override
public Customer getUserInfo(String token) throws Exception {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
Customer customer = customerMapper.selectById(gogirlToken.getCustomerId());
CustomerDetail customerDetail = customerDetailMapper.selectOne(new LambdaQueryWrapper<CustomerDetail>().eq(CustomerDetail::getCustomerId, customer.getId()));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
customer.setCustomerDetail(customerDetail);
customer.setCustomerBalance(customerBalance);
if (StringUtils.isEmpty(customer.getMyQrcode()) && StringUtils.isNotEmpty(customer.getPhone())) {
String myQrCode = qrCodeService.myQrCode(customer.getId().toString(), customer.getPhone());
customer.setMyQrcode(myQrCode);
customer.setId(customer.getId());
customer.setMyQrcode(myQrCode);
customerMapper.updateById(customer);
}
return customer;
}
//todo 替换成hashcode
//字符串中所有字符相加得到一个int
private int openid1GetInt(String openid1) {
StringBuilder sb = new StringBuilder(openid1);
int sum = 0;
int length = sb.length();
for (int i = 20; i < length; i++) {
sum += sb.charAt(i);
}
return sum;
}
/**
* 将emoji表情替换成空串
*
* @param source
* @return 过滤后的字符串
*/
private static String filterEmoji(String source) {
if (source != null && source.length() > 0) {
return source.replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", "");
} else {
return source;
}
}
}
......@@ -13,6 +13,15 @@ public interface WechatService {
* @param code
* @return
*/
Code2SessionResult getOpenidByCode(String code);
Code2SessionResult getCustomerOpenidByCode(String code);
/**
* 根据code获得openid和accessToken
*
* @param code
* @return
*/
Code2SessionResult getTechnicianOpenidByCode(String code);
}
......@@ -19,7 +19,7 @@ public class WechatServiceImpl implements WechatService {
private final WxProperties wxProperties;
@Override
public Code2SessionResult getOpenidByCode(String code) {
public Code2SessionResult getCustomerOpenidByCode(String code) {
String url = WxUrlType.OAuth2_ACCESS_TOKEN_URL
.replaceAll("APPID", wxProperties.getCustomerMiniAppId())
......@@ -31,4 +31,18 @@ public class WechatServiceImpl implements WechatService {
return JsonUtilByFsJson.jsonToBean(response, Code2SessionResult.class);
}
@Override
public Code2SessionResult getTechnicianOpenidByCode(String code) {
String url = WxUrlType.OAuth2_ACCESS_TOKEN_URL
.replaceAll("APPID", wxProperties.getStoreMiniAppId())
.replaceAll("SECRET", wxProperties.getStoreMiniSecret())
.replaceAll("JSCODE", code);
String response = restTemplate.postForEntity(url, null, String.class).getBody();
return JsonUtilByFsJson.jsonToBean(response, Code2SessionResult.class);
}
}
......@@ -3,6 +3,7 @@ package com.gogirl.domain.xcx;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gogirl.domain.store.oa.TakeLeaveEvent;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -37,4 +38,6 @@ public class Message {
private String paramJson;
private TakeLeaveEvent takeLeaveEvent;
}
......@@ -55,12 +55,14 @@ public class MvcInterceptorConfig extends WebMvcConfigurationSupport {
.excludePathPatterns("/customer/mallOrderPay/refund/*")
.excludePathPatterns("/customer/xcx/upload")
.excludePathPatterns("/xcx/login")
.excludePathPatterns("/technician/xcx/login")
.excludePathPatterns("/csrf")
.excludePathPatterns("/xcx/login_t")
.excludePathPatterns("/phone/bindPhone_t")
.excludePathPatterns("/phone/getBindCode")
.excludePathPatterns("/xcx/upload");
.excludePathPatterns("/technician/xcx/login_t")
.excludePathPatterns("/technician/phone/bindPhone_t")
.excludePathPatterns("/technician/phone/getBindCode")
.excludePathPatterns("/technician/xcx/upload")
.excludePathPatterns("/technician/xcx/getUserInfo_t")
.excludePathPatterns("/technician/xcx/choseStore");
;
registry.addInterceptor(logHandlerInterceptor);
......
......@@ -27,12 +27,26 @@ public class LoginHandlerInterceptor implements HandlerInterceptor {
return true;
}
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
if (gogirlToken == null
|| gogirlToken.getCustomerId() == null
|| gogirlToken.getCustomer() == null) {
log.error(request.toString());
throw new RRException(2000, "token失效,请重新登陆");
String sourceFrom = request.getHeader("sourceFrom");
if (sourceFrom.equals("customer")) {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
if (gogirlToken == null
|| gogirlToken.getCustomer() == null
|| gogirlToken.getCustomerId() == null
) {
log.error(request.toString());
throw new RRException(2000, "token失效,请重新登陆");
}
}
if (sourceFrom.equals("technician")) {
GogirlToken technicianGogirlToken = gogirlTokenService.getTokenByToken_t(token);
if (technicianGogirlToken == null
|| technicianGogirlToken.getStoreTechnician() == null
|| technicianGogirlToken.getStoreTechnician().getTechnicianId() == null) {
log.error(request.toString());
throw new RRException(2000, "token失效,请重新登陆");
}
}
return true;
}
......
......@@ -3,7 +3,6 @@ package com.gogirl.infrastructure.mapper.market;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.market.discount.LeisureDiscountConfig;
import com.gogirl.domain.product.serve.BaseServe;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -58,7 +57,6 @@ public interface LeisureDiscountConfigMapper extends BaseMapper<LeisureDiscountC
*/
List<LeisureDiscountConfig> selectByDepartmentIdAndWeekIgnoreLimit(@Param("departmentId") Integer departmentId, @Param("week") int weekday);
/**
* 获取时间,服务,周几对应的折扣列表
*
......@@ -67,5 +65,5 @@ public interface LeisureDiscountConfigMapper extends BaseMapper<LeisureDiscountC
* @param weekday 周几
* @return 折扣列表
*/
List<LeisureDiscountConfig> selectIsLeisureTime(String time, Integer serveId, int weekday);
List<LeisureDiscountConfig> selectIsLeisureTime(@Param("time") String time, @Param("serveId") Integer serveId, @Param("week") int weekday);
}
......@@ -15,4 +15,6 @@ import java.util.List;
public interface ScheduleServeMapper extends BaseMapper<ScheduleServe> {
List<ScheduleServe> selectConflictType(@Param("scheduledUser") Integer scheduledUser, @Param("days") Date days, @Param("serveTypeName") String serveTypeName);
void queryByProduceId(Integer produceId);
}
package com.gogirl.infrastructure.util.lock;
import java.util.HashMap;
import java.util.concurrent.locks.ReentrantLock;
/**
*  * 分段锁,系统提供一定数量的原始锁,根据传入用户id值获取对应的锁并加锁  * 注意:要锁的用户id值如果发生改变,有可能导致锁无法成功释放!!!
*/
public class ScheduledLock {
private final static HashMap<Integer, ReentrantLock> lockMap = new HashMap<>();
private Integer segments = 500;// 默认分段数量
private ScheduledLock() {
init(null, false);
}
private ScheduledLock(Integer counts, boolean fair) {
init(counts, fair);
}
/*静态内部类实现单例*/
public static final ScheduledLock getInsatance() {
return SingletonHolder.instance;
}
private void init(Integer counts, boolean fair) {
if (counts != null) {
segments = counts;
}
for (int i = 0; i < segments; i++) {
lockMap.put(i, new ReentrantLock(fair));
}
}
public void lock(int key) {
ReentrantLock lock = lockMap.get(key % segments);
lock.lock();
}
public void unlock(int key) {
ReentrantLock lock = lockMap.get(key % segments);
lock.unlock();
}
@Override
public String toString() {
return "SegmentLock [segments=" + segments + ", lockMap=" + lockMap
+ "]";
}
/*静态内部类实现单例*/
private static class SingletonHolder {
private static final ScheduledLock instance = new ScheduledLock(null, true);
}
}
......@@ -9,10 +9,11 @@ import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.assembler.ScheduleManageDTOAssembler;
import com.gogirl.domain.order.serve.ScheduleManage;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.dto.IdleTimeProgramQuery;
import com.gogirl.infrastructure.common.annotation.GogirlShop;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.dto.IdleTimeProgramQuery;
import com.gogirl.infrastructure.util.lock.ScheduledLock;
import com.gogirl.shared.order.serve.command.schedule.CancelScheduleCommand;
import com.gogirl.shared.order.serve.command.schedule.SubmitScheduleCommand;
import com.gogirl.shared.order.serve.command.schedule.UpdateScheduleCommand;
......@@ -79,29 +80,41 @@ public class ScheduleManageController {
@ApiOperation(value = "用户取消预约")
@PostMapping("/customer/schedule/cancelOrder")
public JsonResult<Void> cancelSchedule(@RequestBody CancelScheduleCommand cmd) {
scheduleManageService.cancelSchedule(cmd);
ScheduledLock scheduledLock = ScheduledLock.getInsatance();
try {
log.info("用户取消预约:{}", cmd);
scheduledLock.lock(cmd.getScheduleId());
scheduleManageService.cancelSchedule(cmd);
} finally {
scheduledLock.unlock(cmd.getScheduleId());
}
return JsonResult.success();
}
@ApiOperation("更新预约")
@ApiOperation("用户更新预约")
@PostMapping("/customer/schedule/updateSchedule")
public JsonResult<Void> updateSchedule(@RequestHeader String token,
@RequestBody UpdateScheduleCommand cmd) {
log.info("更新预约:{}", cmd);
Integer currentCustomerId = Optional.ofNullable(gogirlTokenService.getTokenByToken(token).getCustomerId())
.orElseThrow(() -> new RRException(500, "token不存在"));
cmd.getScheduleManageDTO().setScheduledUser(currentCustomerId);
scheduleManageService.updateSchedule(cmd);
ScheduledLock scheduledLock = ScheduledLock.getInsatance();
try {
log.info("用户更新预约:{}", cmd);
scheduledLock.lock(cmd.getScheduleManageDTO().getId());
scheduleManageService.updateSchedule(cmd);
} finally {
scheduledLock.unlock(cmd.getScheduleManageDTO().getId());
}
return JsonResult.success();
}
@ApiOperation(value = "根据id查询预约详情")
@GetMapping("/customer/schedule/queryScheduleManage")
public JsonResult<ScheduleManageDTO> queryScheduleManage(@RequestParam Integer id) {
ScheduleManageQuery qry = new ScheduleManageQuery();
qry.setScheduleManageId(id);
ScheduleManage scheduleManage = scheduleManageService.queryScheduleManage(qry);
ScheduleManage scheduleManage = scheduleManageService.queryScheduleManage(id);
return JsonResult.success(scheduleManageDTOAssembler.apply(scheduleManage));
}
......@@ -162,20 +175,12 @@ public class ScheduleManageController {
@ApiOperation(value = "根据id查询预约详情")
@GetMapping("/technician/schedule/queryScheduleManage")
public JsonResult<ScheduleManageDTO> technicianQueryScheduleManage(@RequestParam Integer id) {
ScheduleManageQuery qry = new ScheduleManageQuery();
qry.setScheduleManageId(id);
ScheduleManage scheduleManage = scheduleManageService.queryScheduleManage(qry);
ScheduleManage scheduleManage = scheduleManageService.queryScheduleManage(id);
ScheduleManageDTO scheduleManageDTO = scheduleManageDTOAssembler.apply(scheduleManage);
scheduleManageDTO.getScheduleServeDTOList().forEach(scheduleServeDTO -> {
//如果预约服务有款式 就查询款式使用色号
//todo如果预约服务有款式 就查询款式使用色号
if (scheduleServeDTO.getProduceId() != null) {
// List<PurchaseSkuDTO> purchaseSkuDTOList =
// purchaseSkuService.
// purchaseSkuControllerFeign.queryByProduceId(scheduleServeDTO.getProduceId()).getData();
// scheduleServeDTO.setPurchaseSkuDTOList(purchaseSkuDTOList);
}
});
return JsonResult.success(scheduleManageDTO);
......
......@@ -9,6 +9,7 @@ import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.domain.xcx.VisitsLog;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.mapper.xcx.MessageMapper;
import com.gogirl.shared.user.command.ReadMessageCommand;
import com.gogirl.shared.user.query.qry.CustomerMessagePageQuery;
import io.swagger.annotations.Api;
......@@ -103,4 +104,7 @@ public class MessageController {
visitLogService.pageOut(visitsId);
return JsonResult.success();
}
}
package com.gogirl.interfaces.xcx;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gogirl.application.order.serve.OrderManageService;
import com.gogirl.application.order.serve.ScheduleManageService;
import com.gogirl.application.store.store.StoreTechnicianService;
import com.gogirl.application.user.customer.CustomerService;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.application.xcx.QRCodeService;
import com.gogirl.application.xcx.WechatService;
import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.order.serve.ScheduleManage;
import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.user.Customer;
import com.gogirl.domain.user.CustomerBalance;
import com.gogirl.domain.user.CustomerDetail;
import com.gogirl.domain.xcx.GogirlToken;
import com.gogirl.infrastructure.common.annotation.GogirlMember;
import com.gogirl.infrastructure.common.annotation.GogirlShop;
import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.config.GogirlProperties;
import com.gogirl.infrastructure.mapper.order.serve.ScheduleManageMapper;
import com.gogirl.infrastructure.mapper.user.CustomerBalanceMapper;
import com.gogirl.infrastructure.mapper.user.CustomerDetailMapper;
import com.gogirl.infrastructure.mapper.user.CustomerMapper;
import com.gogirl.infrastructure.mapper.xcx.GogirlTokenMapper;
import com.gogirl.infrastructure.util.ImageUtil;
import com.gogirl.infrastructure.util.WXCore;
import com.gogirl.infrastructure.util.lock.Openid1Lock;
import com.gogirl.shared.member.wx.query.dto.Code2SessionResult;
import com.gogirl.shared.user.query.qry.CustomerQuery;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RestController
......@@ -65,7 +46,6 @@ public class XcxController {
private final QRCodeService qrCodeService;
private final CustomerBalanceMapper customerBalanceMapper;
private final CustomerDetailMapper customerDetailMapper;
private final ScheduleManageMapper scheduleManageMapper;
private final ScheduleManageService scheduleManageService;
private final StoreTechnicianService storeTechnicianService;
private final OrderManageService orderManageService;
......@@ -91,14 +71,7 @@ public class XcxController {
@RequestParam String city,
@RequestParam String area,
@RequestParam String street) {
Customer customer = customerMapper.selectById(customerId);
customer.setProvince(province);
customer.setCity(city);
customer.setArea(area);
customer.setStreet(street);
customerMapper.updateById(customer);
customerService.bindAddressInfo(customerId, province, city, area, street);
return JsonResult.success();
}
......@@ -109,131 +82,24 @@ public class XcxController {
return JsonResult.success(customer);
}
private final CustomerService customerService;
@ApiOperation(value = "客户根据code获取token")
@RequestMapping(method = {RequestMethod.GET}, value = "/customer/xcx/login")
@GetMapping("/customer/xcx/login")
public JsonResult<String> login(@RequestParam String code) {
log.info("调用login,授权用户信息到程序 code:{}", code);
Openid1Lock lock = Openid1Lock.getInsatance();
Code2SessionResult result = wechatService.getOpenidByCode(code);
String token = IdWorker.getIdStr();
//创建token
GogirlToken gogirlToken = GogirlToken.builder()
.code(code)
.sysId(1)
.openid(result.getOpenid())
.sessionKey(result.getSessionKey())
.createTime(new Date())
.updateTime(new Date())
.unionid(result.getUnionid())
.token(token)
.build();
String openid = gogirlToken.getOpenid();
try {
lock.lock(openid1GetInt(openid));
//变量为当前登陆用户
Customer customer;
customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, openid));
//不存在小程序用户
if (customer == null) {
//token unionid 不为空
if (StringUtils.isNotEmpty(result.getUnionid())) {
customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getUnionid, result.getUnionid()));
//不存在公众号用户
if (customer == null) {
customer = Customer.builder()
.customerSource(4)
//小程序openid
.openid1(openid)
.orderTimes(0)
.registerTime(new Date())
.scheduledTimes(0)
//微信授权
.source(3)
//状态 正常
.state("1")
.updateTime(new Date())
.build();
customerMapper.insert(customer);
}
// 存在公众号用户
else {
customer.setOpenid1(openid);
customerMapper.updateById(customer);
}
}
//union id为空
else {
customer = Customer.builder()
.customerSource(4)
//小程序openid
.openid1(openid)
.orderTimes(0)
.registerTime(new Date())
.scheduledTimes(0)
//微信授权
.source(3)
//状态 正常
.state("1")
.updateTime(new Date())
.build();
customerMapper.insert(customer);
}
}
gogirlToken.setCustomerId(customer.getId());
gogirlTokenMapper.insert(gogirlToken);
} finally {
lock.unlock(openid1GetInt(openid));
}
String token = customerService.login(code);
return JsonResult.success(token);
}
@ApiOperation(value = "客户授权后绑定个人信息")
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/customer/xcx/authorized1")
public JsonResult<Customer> Authorization1(
public JsonResult<Customer> authorized1(
@RequestParam(name = "token", required = false) String token,
@RequestParam(name = "encryptedData", required = false) String encryptedData,
@RequestParam(name = "iv", required = false) String iv) throws InvalidAlgorithmParameterException {
log.info("调用authorized,授权用户信息到程序");
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
JSONObject data = WXCore.decrypt(encryptedData, gogirlToken.getSessionKey(), iv);
String unionid = (String) data.get("unionId");
String openid = (String) data.get("openId");
Integer gender = (Integer) data.get("gender");
String avatarUrl = (String) data.get("avatarUrl");
String city = (String) data.get("city");
String country = (String) data.get("country");
String province = (String) data.get("province");
String nickName = filterEmoji((String) data.get("nickName"));
Customer customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, openid));
customer.setSex(gender == 1 ? "男" : gender == 2 ? "女" : "未知");
customer.setHeadimgurl(avatarUrl);
customer.setNickname(nickName);
customer.setProvince(province);
customer.setCountry(country);
customer.setCity(city);
customer.setUnionid(unionid);
customerMapper.updateById(customer);
Customer customer = customerService.authorized1(token, encryptedData, iv);
return JsonResult.success(customer);
}
......@@ -242,99 +108,21 @@ public class XcxController {
public JsonResult<Customer> authorizedPhone(@RequestHeader String token,
@RequestParam String encryptedData,
@RequestParam String iv) throws InvalidAlgorithmParameterException {
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
log.info("手机号码授权,用户信息:" + gogirlToken.getCustomer());
JSONObject data = WXCore.decrypt(encryptedData, gogirlToken.getSessionKey(), iv);
String phone = (String) data.get("purePhoneNumber");
gogirlToken.setPhone(phone);
gogirlTokenMapper.updateById(gogirlToken);
Customer customer = customerMapper.selectById(gogirlToken.getCustomerId());
Customer phoneCustomer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getPhone, phone));
//如果存在手机号
if (phoneCustomer != null) {
phoneCustomer.setSex(customer.getSex());
phoneCustomer.setHeadimgurl(customer.getHeadimgurl());
phoneCustomer.setNickname(customer.getNickname());
phoneCustomer.setProvince(customer.getProvince());
phoneCustomer.setCountry(customer.getCountry());
phoneCustomer.setCity(customer.getCity());
phoneCustomer.setUnionid(customer.getUnionid());
phoneCustomer.setCustomerSource(customer.getCustomerSource());
phoneCustomer.setOpenid1(customer.getOpenid1());
phoneCustomer.setRegisterTime(customer.getRegisterTime());
phoneCustomer.setScheduledTimes(customer.getScheduledTimes());
phoneCustomer.setSource(customer.getSource());
phoneCustomer.setState(customer.getState());
phoneCustomer.setUpdateTime(new Date());
customerMapper.updateById(phoneCustomer);
customerMapper.deleteById(customer);
List<ScheduleManage> scheduleManageList = scheduleManageService.list(new LambdaQueryWrapper<ScheduleManage>()
.eq(ScheduleManage::getTelephone, phone));
if (ListUtil.isNotEmpty(scheduleManageList)) {
// scheduleManageService.
scheduleManageList.forEach(scheduleManage -> scheduleManage.setTelephone(phone));
scheduleManageService.saveBatch(scheduleManageList);
}
//清除token
gogirlTokenMapper.delete(new LambdaQueryWrapper<GogirlToken>().eq(GogirlToken::getCustomerId, customer.getId()));
return JsonResult.success(phoneCustomer);
}
//不存在手机号
else {
customer.setPhone(phone);
customerMapper.updateById(customer);
return JsonResult.success(customer);
}
log.info("手机号码授权,用户信息:");
Customer customer = customerService.authorizedPhone(token, encryptedData, iv);
return JsonResult.success();
}
@RequestMapping(method = {RequestMethod.GET}, value = "/customer/xcx/getUserInfo")
@GetMapping("/customer/xcx/getUserInfo")
@ApiOperation(value = "客户根据token获取用户信息")
@ApiImplicitParam(paramType = "query", name = "token", value = "token编号", required = true, dataType = "String")
@GogirlMember
public JsonResult<Customer> getUserInfo(@RequestParam String token) throws Exception {
log.info("根据token:" + token + ",查询用户信息.");
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
Customer customer = customerMapper.selectById(gogirlToken.getCustomerId());
CustomerDetail customerDetail = customerDetailMapper.selectOne(new LambdaQueryWrapper<CustomerDetail>().eq(CustomerDetail::getCustomerId, customer.getId()));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
customer.setCustomerDetail(customerDetail);
customer.setCustomerBalance(customerBalance);
if (StringUtils.isEmpty(customer.getMyQrcode()) && StringUtils.isNotEmpty(customer.getPhone())) {
String myQrCode = qrCodeService.myQrCode(customer.getId().toString(), customer.getPhone());
customer.setMyQrcode(myQrCode);
customer.setId(customer.getId());
customer.setMyQrcode(myQrCode);
customerMapper.updateById(customer);
}
Customer customer = customerService.getUserInfo(token);
return JsonResult.success(customer);
}
@ApiOperation(value = "图片上传")
@RequestMapping(method = {RequestMethod.POST}, value = "/customer/xcx/upload")
@GogirlMember
@GogirlShop
@PostMapping("/customer/xcx/upload")
public JsonResult<String> upload(MultipartFile file) throws Exception {
log.info("图片上传");
if (file == null) {
......@@ -347,92 +135,22 @@ public class XcxController {
@ApiOperation(value = "美甲师根据code获取token")
@GetMapping(value = "/technician/xcx/login_t")
public JsonResult<String> login_t(@RequestParam String code) {
log.info("调用login,授权用户信息到程序 code:{} 获取用户信息 ", code);
Code2SessionResult responseResult = wechatService.getOpenidByCode(code);
if (responseResult.getErrcode() != null) {
throw new RRException(responseResult.getErrmsg());
}
String openid = responseResult.getOpenid();
//生成token
String token = new BigInteger((int) (Math.random() * 1000) + new SimpleDateFormat("ddHHmmss").format(new Date()), 10).toString(16);
StoreTechnician param = new StoreTechnician();
param.setOpenid(openid);
List<StoreTechnician> list = storeTechnicianService.listTechnicianForPage(param);
GogirlToken gogirlToken = new GogirlToken();
if (ListUtil.isNotEmpty(list) && list.size() == 1) {
gogirlToken.setCustomerId(list.get(0).getId());
gogirlTokenMapper.updateById(gogirlToken);
}
//美甲师token
gogirlToken.setSysId(2);
gogirlToken.setOpenid(openid);
// 返回美甲师信息及token
gogirlToken.setCreateTime(new Date());
gogirlToken.setUpdateTime(new Date());
gogirlToken.setToken(token);
gogirlTokenMapper.insert(gogirlToken);
String token = storeTechnicianService.login(code);
return JsonResult.success(token);
}
@ApiOperation(value = "美甲师根据token获取美甲师信息")
@GetMapping("/technician/xcx/getUserInfo_t")
@GogirlShop
public JsonResult<List<StoreTechnician>> getUserInfo_t(String token) {
log.info("根据token:" + token + ",查询用户信息.");
GogirlToken gogirlToken = gogirlTokenService.getTokenByToken(token);
//获取美甲师信息
if (gogirlToken.getCustomerId() != null) {
StoreTechnician storeTechnician = storeTechnicianService.getTechnicianManageForDetail(gogirlToken.getCustomerId());
List<StoreTechnician> list = Lists.newArrayList(storeTechnician);
return JsonResult.success(list);
}
//token customerId为空
else {
StoreTechnician param = new StoreTechnician();
param.setOpenid(gogirlToken.getOpenid());
List<StoreTechnician> list = storeTechnicianService.listTechnicianForPage(param);
//选择门店
if (ListUtil.isNotEmpty(list) && list.size() > 1) {
log.info("美甲师选择门店");
}
//set customerId
else if (ListUtil.isNotEmpty(list) && list.size() == 1) {
gogirlToken.setCustomerId(list.get(0).getId());
gogirlTokenMapper.updateById(gogirlToken);
log.info("存在美甲师, setCustomerId (ssa.id)");
}
//list is empty
else {
log.info("绑定手机号");
}
return JsonResult.success(list);
}
List<StoreTechnician> list = storeTechnicianService.getTechnicianInfo(token);
return JsonResult.success(list);
}
@ApiOperation(value = "美甲师选择多门店的账号")
@RequestMapping(method = {RequestMethod.POST}, value = "/technician/xcx/choseStore")
@GogirlShop
@PostMapping("/technician/xcx/choseStore")
public JsonResult<StoreTechnician> choseStore(@RequestParam(name = "token") String token,
@RequestParam(name = "technicianId") Integer technicianId) {
log.info("美甲师选择多门店的账号");
......@@ -447,68 +165,22 @@ public class XcxController {
}
@ApiOperation(value = "美甲师选择多门店的账号-根据订单id")
@RequestMapping(method = {RequestMethod.POST}, value = "/technician/xcx/choseStoreByOrderId")
public JsonResult<StoreTechnician> choseStoreByOrderId(
@RequestParam(name = "token") String token,
@RequestParam(name = "orderId") Integer orderId) {
@PostMapping("/technician/xcx/choseStoreByOrderId")
public JsonResult<StoreTechnician> choseStoreByOrderId(@RequestParam(name = "token") String token,
@RequestParam(name = "orderId") Integer orderId) {
log.info("美甲师选择多门店的账号");
if (token == null || token.isEmpty()) {
return new JsonResult<>(false, "入参token为空", null);
}
if (orderId == null) {
return new JsonResult<>(false, "入参orderId为空", null);
}
GogirlToken gt = gogirlTokenService.getTokenByToken(token);
if (gt == null) {
return new JsonResult<>(false, "token过期", null);
}
OrderManage orderManage = orderManageService.queryOrder(orderId);
if (orderManage == null) {
return new JsonResult<>(false, "找不到订单", null);
}
if (orderManage.getDepartmentId() == null) {
return new JsonResult<>(false, "订单无店铺", null);
}
List<StoreTechnician> listStoreTechnician = storeTechnicianService.getTechnicianManageByOpenid(gt.getOpenid());
if (listStoreTechnician == null) {
return new JsonResult<>(false, "找不到该美甲师账号", null);
}
for (StoreTechnician storeTechnician : listStoreTechnician) {
if (storeTechnician.getDepartmentId().equals(orderManage.getDepartmentId())) {
GogirlToken gogirlToken = new GogirlToken();
gogirlToken.setId(gt.getId());
gogirlToken.setCustomerId(storeTechnician.getId());
gogirlTokenService.updateByPrimaryKeySelective(gogirlToken);
return new JsonResult<>(true, JsonResult.APP_DEFINE_SUC, storeTechnician);
}
}
return new JsonResult<>(true, "无该店铺");
StoreTechnician storeTechnician = storeTechnicianService.choseStoreByOrderId(token, orderId);
return JsonResult.success(storeTechnician);
}
@ApiOperation(value = "图片上传")
@RequestMapping(method = {RequestMethod.POST}, value = "/technician/xcx/upload")
@GogirlMember
@GogirlShop
@PostMapping("/technician/xcx/upload")
public JsonResult<String> techUpload(MultipartFile file) throws Exception {
log.info("美甲师选择多门店的账号");
if (file == null) {
return new JsonResult<>(false, "file为空", null);
}
String imgUrl = ImageUtil.saveImage(gogirlProperties.getPicturePath(), file);
return new JsonResult<>(true, JsonResult.APP_DEFINE_SUC, imgUrl);
}
//字符串中所有字符相加得到一个int
private int openid1GetInt(String openid1) {
StringBuilder sb = new StringBuilder(openid1);
int sum = 0;
int length = sb.length();
for (int i = 20; i < length; i++) {
sum += sb.charAt(i);
}
return sum;
return JsonResult.success(imgUrl);
}
}
......@@ -114,7 +114,6 @@ public class ScheduleServeDTO implements Serializable {
@ApiModelProperty("实际结束时间")
private Date actualEndTime;
private Integer leisureDiscountConfigId;
private List<PurchaseSkuDTO> purchaseSkuDTOList;
......
......@@ -24,7 +24,7 @@ spring:
name: gogirl-wxapp-member-backend
#数据配置
datasource:
url: jdbc:mysql://gz-cdb-c0sq6eax.sql.tencentcdb.com:60779/gogirl_pre?useUnicode=true&characterEncoding=utf-8&useSSL=false
url: jdbc:mysql://gz-cdb-c0sq6eax.sql.tencentcdb.com:60779/gogirl_pre?useUnicode=true&characterEncoding=utf-8&useSSL=false&&zeroDateTimeBehavior=convertToNull
username: root
password: "#7kfnymAM$Y9-Ntf"
driver-class-name: com.mysql.jdbc.Driver
......@@ -33,17 +33,17 @@ spring:
#项目属性
gogirl:
#充值回调地址
notify-charge: "http://t.begogirls.com/miniapp/customer/pay/notifyCharge"
notify-charge: "http://t.begogirls.com/customer/pay/notifyCharge"
#次卡购买回调地址
notify-timescard: "http://t.begogirls.com/miniapp/customer/pay/notifyTimesCard"
notify-timescard: "http://t.begogirls.com/customer/pay/notifyTimesCard"
#预约订单支付回调地址
notify-order: "http://t.begogirls.com/miniapp/customer/pay/notifyOrder"
notify-order: "http://t.begogirls.com/miniapp/pay/notifyOrder"
#商城订单支付回调
notify-mall-order: "http://t.begogirls.com/miniapp/customer/mallOrderPay/notifyMallOrder"
notify-mall-order: "http://t.begogirls.com/customer/mallOrderPay/notifyMallOrder"
#商城退款订单回调
notify-refund-mall-order: "http://t.begogirls.com/miniapp/customer/mallOrderPay/notifyRefundMallOrder"
notify-refund-mall-order: "http://t.begogirls.com/customer/mallOrderPay/notifyRefundMallOrder"
notify-balance-wx-pay: "http://t.begogirls.com/miniapp/customer/pay/notifyBalanceWxPay"
notify-balance-wx-pay: "http://t.begogirls.com/customer/pay/notifyBalanceWxPay"
#服务器图片临时地址
picture-path: /upload/grouppic/
......@@ -55,4 +55,4 @@ eureka:
defaultZone: http://127.0.0.1:1111/eureka/
server:
port: 5555
\ No newline at end of file
port: 5444
\ No newline at end of file
......@@ -25,7 +25,7 @@ spring:
name: gogirl-wxapp-member-backend
# 数据配置
datasource:
url: jdbc:mysql://gz-cdb-c0sq6eax.sql.tencentcdb.com:60779/bailun_gogirl?useUnicode=true&characterEncoding=utf-8&useSSL=false
url: jdbc:mysql://gz-cdb-c0sq6eax.sql.tencentcdb.com:60779/bailun_gogirl?useUnicode=true&characterEncoding=utf-8&useSSL=false&&zeroDateTimeBehavior=convertToNull
username: root
password: "#7kfnymAM$Y9-Ntf"
driver-class-name: com.mysql.jdbc.Driver
......@@ -34,17 +34,17 @@ spring:
#项目属性
gogirl:
#充值回调地址
notify-charge: "http://www.begogirls.com/miniapp/customer/pay/notifyCharge"
notify-charge: "http://www.begogirls.com/customer/pay/notifyCharge"
#次卡购买回调地址
notify-timescard: "http://www.begogirls.com/miniapp/customer/pay/notifyTimesCard"
notify-timescard: "http://www.begogirls.com/customer/pay/notifyTimesCard"
#预约订单支付回调地址
notify-order: "http://www.begogirls.com/miniapp/customer/pay/notifyOrder"
notify-order: "http://www.begogirls.com/customer/pay/notifyOrder"
#商城订单支付回调
notify-mall-order: "http://www.begogirls.com/miniapp/customer/mallOrderPay/notifyMallOrder"
notify-mall-order: "http://www.begogirls.com/customer/mallOrderPay/notifyMallOrder"
#商城退款订单回调
notify-refund-mall-order: "http://www.begogirls.com/miniapp/customer/mallOrderPay/notifyRefundMallOrder"
notify-refund-mall-order: "http://www.begogirls.com/customer/mallOrderPay/notifyRefundMallOrder"
#
notify-balance-wx-pay: "http://wwww.begogirls.com/miniapp/customer/pay/notifyBalanceWxPay"
notify-balance-wx-pay: "http://wwww.begogirls.com/customer/pay/notifyBalanceWxPay"
#服务器图片临时地址
picture-path: /upload/grouppic/
......@@ -58,4 +58,4 @@ eureka:
server:
port: 8094
port: 5444
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment