Commit bcc4b899 by huluobin

bug fix

parent 7b0c78b9
......@@ -31,4 +31,15 @@ public interface IChargeOrderService extends IService<ChargeOrder> {
* @return
*/
WxPayMpOrderResult customerChargeBalance(Integer chargeId) throws UnknownHostException, WxPayException;
/**
* 美甲师充值会员卡
* @param name
* @param phone
* @param amount
* @param source
* @param refereeId
* @param remark
*/
void chargeCustomerCard(String name, String phone, Double amount, Integer source, String refereeId, String remark);
}
......@@ -7,7 +7,11 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.gogirl.application.market.CouponService;
import com.gogirl.application.market.DiscountConfigService;
import com.gogirl.application.order.member.IChargeOrderService;
import com.gogirl.application.store.store.CustomerDepartmentRelevanceService;
import com.gogirl.application.user.customer.CustomerService;
import com.gogirl.domain.market.discount.DiscountConfig;
import com.gogirl.domain.order.member.ChargeOrder;
import com.gogirl.domain.user.customer.Customer;
......@@ -24,7 +28,9 @@ import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceRecordMappe
import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper;
import com.gogirl.infrastructure.util.SessionUtils;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.InetAddress;
import java.net.UnknownHostException;
......@@ -42,6 +48,8 @@ import java.util.Date;
*/
@Service
@AllArgsConstructor
@Transactional
@Slf4j
public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, ChargeOrder> implements IChargeOrderService {
private final CustomerMapper customerMapper;
......@@ -49,6 +57,7 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
private final CustomerBalanceMapper customerBalanceMapper;
private final CustomerBalanceRecordMapper customerBalanceRecordMapper;
private final CouponService couponService;
@Override
public void notifyChargeOrder(WxPayOrderNotifyResult result) {
......@@ -57,6 +66,7 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
throw new RRException();
}
Customer customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, result.getOpenid()));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
......@@ -65,6 +75,9 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
.stream().filter(config -> config.getChargeAmount() <= result.getTotalFee())
.max(Comparator.comparing(DiscountConfig::getChargeAmount)).orElseThrow(RRException::new);
couponService.sendCoupon(discountConfig.getCouponId(), customer.getId());
//首次充值
if (customerBalance == null || customerBalance.getBalance() == 0) {
customerBalance = CustomerBalance.builder()
......@@ -175,4 +188,84 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
WxPayMpOrderResult result = wxPayControllerFeign.createJsapiOrder(request);
return result;
}
private final CustomerService customerService;
private final CustomerDepartmentRelevanceService customerDepartmentRelevanceService;
private final DiscountConfigService discountConfigService;
@Override
public void chargeCustomerCard(String name, String phone, Double amount, Integer source, String refereeId, String remark) {
Customer customer = customerService.selectByPhone(phone);
GogirlToken gogirlToken = SessionUtils.getTechnicianToken();
Integer departmentId = gogirlToken.getDepartmentId();
log.info("{} 充值给 {}", gogirlToken.getTechnicianId(), phone);
//新建会员
if (customer == null) {
customer = new Customer();
customer.setStoreRecordRealName(name);
customer.setPhone(phone);
customerService.save(customer);
}
//更新会员的店员记录名字
else if (name != null && !name.isEmpty()) {
customer.setStoreRecordRealName(name);
customerService.updateById(customer);
}
//店铺会员关联
customerDepartmentRelevanceService.insertDepartmentRelevanceIfNotExist(customer.getId(), departmentId, 4, new Date());
//折扣信息
DiscountConfig discountConfig = discountConfigService.selectByCharge((int) (amount * 100));
//会员卡
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>()
.eq(CustomerBalance::getCustomerId, customer.getId()));
//充值类型
Integer type = customerBalance == null ? 2 : 1;
//如果会员卡不存在就新增会员卡
if (customerBalance == null) {
customerBalance = CustomerBalance.getInstance(customer.getId());
customerBalanceMapper.insert(customerBalance);
}
int chargeAmount = (int) (amount * 100);
//充值订单id
String orderId = IdWorker.getIdStr();
//更新余额
customerBalance.setBalance(customerBalance.getBalance() + chargeAmount);
customerBalance.setTotalCharge(customerBalance.getTotalCharge() + chargeAmount);
customerBalance.setUpdateTime(new Date());
//会员等级
customerBalance.setLevel(discountConfig.getLevel());
customerBalanceMapper.updateById(customerBalance);
//充值流水
CustomerBalanceRecord customerBalanceRecord = CustomerBalanceRecord.builder()
.currentBalance(customerBalance.getBalance())
.customerId(customer.getId())
//充送金额由定时任务计算
.bestowAmount(0)
.departmentId(gogirlToken.getDepartmentId())
.departmentName(gogirlToken.getDepartmentName())
.discount(1d)
.orderAmount(chargeAmount)
.orderId(orderId)
//支付方式
.source(source)
.refereeId(refereeId)
.remark(remark)
//订单类型
.type(type)
.time(new Date())
.build();
customerBalanceRecordMapper.insert(customerBalanceRecord);
}
}
......@@ -13,7 +13,7 @@ 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;
import com.gogirl.shared.order.serve.query.dto.IdleTimeDTO;
import com.gogirl.shared.order.serve.query.qry.StoreTechnicianQuery;
import com.gogirl.shared.order.serve.query.qry.StoreTechnicianPeriod;
import com.gogirl.shared.order.serve.query.qry.schedule.ScheduleManagePageQuery;
import java.text.ParseException;
......@@ -151,7 +151,17 @@ public interface ScheduleManageService extends IService<ScheduleManage> {
*/
IPage<LeisureScheduleServe> queryPageLeisureScheduleServe(LeisureScheduleServeQuery query);
List<StoreTechnicianQuery> storeTechnicianQueryList(Integer scheduledId,
/**
* 查询美甲师不可用时间段
*
* @param scheduledId 是否必传 否
* @param departmentId 店铺id
* @param scheduleDate localData
* @param serveIdList 预约的服务id
* @return
* @throws ParseException
*/
List<StoreTechnicianPeriod> queryStoreTechnicianPeriod(Integer scheduledId,
Integer departmentId,
String scheduleDate,
List<Integer> serveIdList) throws ParseException;
......
......@@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gogirl.application.market.CouponCustomerRelevanceService;
import com.gogirl.application.market.CouponService;
import com.gogirl.application.market.MarketService;
import com.gogirl.application.market.TimesCardUsedRecordService;
import com.gogirl.application.order.serve.OrderManageService;
......@@ -16,6 +17,7 @@ import com.gogirl.application.order.serve.OrderServeSkuService;
import com.gogirl.application.user.customer.CustomerBalanceService;
import com.gogirl.application.user.customer.CustomerService;
import com.gogirl.application.xcx.GogirlTokenService;
import com.gogirl.domain.market.coupon.Coupon;
import com.gogirl.domain.market.coupon.CouponCustomerRelevance;
import com.gogirl.domain.market.timescard.TimesCardUsedRecord;
import com.gogirl.domain.order.serve.*;
......@@ -316,8 +318,10 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
orderManage.setScheduleManage(list.stream().findAny().orElse(null));
}
orderManage.getListOrderServer().forEach(orderServe -> {
if(orderServe.getEndTime()!=null && orderServe.getStartTime()!=null){
orderServe.setActualServeDuration((int) (orderServe.getEndTime().getTime() -
orderServe.getStartTime().getTime()) / 1000 / 60);
}
});
});
......@@ -435,6 +439,8 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
}
private final CouponService couponService;
@Override
public void recordOrderData(Integer orderId, String remark, String userFeedback, String picturePath, String afterSaleIsBuyCard, String afterSaleBuyCardReason) {
......@@ -606,6 +612,17 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
orderManage.setStatus(OrderManage.STATUS_FINISHED);
//订单已完成
orderManageMapper.updateById(orderManage);
//如果全部项评论了
if (orderServeList.stream().noneMatch(orderServe -> orderServe.getCommentStatus().equals(OrderServe.COMMENT_STATUS_NO))) {
orderManage.setStatus(OrderManage.STATUS_FINISHED);
Coupon coupon = couponService.getOne(new LambdaQueryWrapper<Coupon>().eq(Coupon::getName, "评价礼券"));
if (coupon != null) {
couponService.sendCoupon(coupon.getId(), orderManage.getOrderUser());
}
orderManageMapper.updateById(orderManage);
}
return orderServeList;
}
......
......@@ -10,6 +10,7 @@ import com.gogirl.domain.product.serve.BaseFeatures;
import com.gogirl.domain.product.serve.BaseProduce;
import com.gogirl.domain.product.serve.PraiseRecord;
import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.product.serve.BaseFeaturesMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseProduceMapper;
import com.gogirl.infrastructure.mapper.product.serve.PraiseRecordMapper;
......@@ -19,6 +20,8 @@ import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
......@@ -52,6 +55,21 @@ public class BaseProduceServiceImpl extends ServiceImpl<BaseProduceMapper, BaseP
//排序条件 1-saleNum 2-index_sort
Integer sort = baseFeatures != null && baseFeatures.getName().equals("热销款") ? 1 : 2;
page = baseProduceMapper.queryProducePage(page, featuresId, serveTypeId, sort);
List<Integer> produceIds = page.getRecords().stream().map(BaseProduce::getId).collect(Collectors.toList());
List<PraiseRecord> praiseRecordList = praiseRecordMapper.selectList(new LambdaQueryWrapper<PraiseRecord>()
.in(PraiseRecord::getServeId, produceIds)
.eq(PraiseRecord::getType, 2));
Map<Integer, List<PraiseRecord>> map = praiseRecordList.stream().collect(Collectors.groupingBy(PraiseRecord::getServeId));
page.getRecords().forEach(baseProduce -> {
List<PraiseRecord> mapPraiseRecordList = map.get(baseProduce.getId());
if (ListUtil.isNotEmpty(mapPraiseRecordList)) {
baseProduce.setPraiseRecord(mapPraiseRecordList.stream().findAny().orElse(null));
} else {
baseProduce.setPraiseRecord(new PraiseRecord());
}
});
return page;
}
......
......@@ -25,7 +25,7 @@ public interface StoreClassesTechnicianService extends IService<StoreClassesTech
/**
* 查询美甲师排班详
* 查询美甲师排班详和美甲师当前正在做的服务
*
* @param userId
* @param days
......@@ -33,6 +33,14 @@ public interface StoreClassesTechnicianService extends IService<StoreClassesTech
*/
List<StoreClassesTechnician> listClassesTechnicianDetail(Integer userId, String days);
/**
* 店铺端查询美甲师可用时间
*
* @param startDate
* @param startTime
* @param departmentId
* @return
*/
List<StoreClassesTechnician> getReservableTime(String startDate, String startTime, Integer departmentId);
/**
......@@ -51,6 +59,4 @@ public interface StoreClassesTechnicianService extends IService<StoreClassesTech
*/
void updateDayTechnicianClasses(ParmTechnicianClasses parmTechnicianClasses) throws ParseException;
List<StoreTechnician> queryDayTechnicianClassesList(Integer departmentId, Date day);
}
......@@ -46,7 +46,6 @@ public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesT
@Override
public List<StoreClassesTechnician> listClassesTechnician(Integer scheduledId, Integer departmentId, String days) {
return storeClassesTechnicianMapper.listClassesTechnician(scheduledId, departmentId, days);
}
......@@ -59,7 +58,7 @@ public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesT
public List<StoreTechnician> queryDayTechnicianClasses(Integer departmentId, Date day) {
//查询店铺下的美甲师
List<StoreTechnician> list = this.queryDayTechnicianClassesList(departmentId, day);
List<StoreTechnician> list = storeTechnicianMapper.queryDayTechnicianClasses(departmentId, day);
list.forEach(storeTechnician -> {
StoreClassesTechnician storeClassesTechnician = storeClassesTechnicianMapper.selectOneClassTech(departmentId, day, storeTechnician.getTechnicianId());
......@@ -166,9 +165,9 @@ public class StoreClassesTechnicianServiceImpl extends ServiceImpl<StoreClassesT
private final StoreTechnicianMapper storeTechnicianMapper;
@Override
public List<StoreTechnician> queryDayTechnicianClassesList(Integer departmentId, Date day) {
return storeTechnicianMapper.queryDayTechnicianClasses(departmentId, day);
}
// @Override
// public List<StoreTechnician> queryDayTechnicianClassesList(Integer departmentId, Date day) {
// return ;
// }
}
package com.gogirl.application.user.investigation.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.market.CouponService;
import com.gogirl.application.store.complaint.ComplaintMainService;
import com.gogirl.application.user.investigation.BaseQuestionService;
import com.gogirl.application.user.investigation.OrderQuestionOptionService;
import com.gogirl.application.user.investigation.TestPaperQuestionService;
import com.gogirl.domain.market.coupon.Coupon;
import com.gogirl.domain.user.investigation.*;
import com.gogirl.infrastructure.mapper.user.investigation.BaseQuestionMapper;
import com.gogirl.infrastructure.mapper.user.investigation.TestPaperCustomerMapMapper;
......@@ -29,6 +32,8 @@ public class BaseQuestionServiceImpl extends ServiceImpl<BaseQuestionMapper, Bas
private final OrderQuestionOptionService orderQuestionOptionService;
private final ComplaintMainService complaintMainService;
private final CouponService couponService;
@Override
public List<BaseQuestion> getTestPaper(Integer currentCustomerId) {
return baseQuestionMapper.getTestPaper(currentCustomerId);
......@@ -69,6 +74,12 @@ public class BaseQuestionServiceImpl extends ServiceImpl<BaseQuestionMapper, Bas
orderQuestionOptionService.saveBatch(list);
complaintMainService.saveComplainsByOrderQuestion(list);
Coupon coupon = couponService.getOne(new LambdaQueryWrapper<Coupon>().eq(Coupon::getName, "问卷调查礼券"));
if (coupon != null) {
couponService.sendCoupon(coupon.getId(), currentCustomerId);
}
}
......
......@@ -34,4 +34,5 @@ public class DiscountConfig {
@ApiModelProperty("备注")
private String remark;
private Integer couponId;
}
......@@ -3,19 +3,22 @@ package com.gogirl.infrastructure.mapper.store.store;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.store.store.StoreClassesTechnician;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* Created by yinyong on 2018/9/20.
*/
@Repository
public interface StoreClassesTechnicianMapper extends BaseMapper<StoreClassesTechnician> {
/**
* 查询美甲师排班和美甲师正在做的服务
*
* @param scheduleId 如果传id正在做的服务要排除这个预约
* @param departmentId 店铺id
* @param days 日志 localDate
* @return
*/
List<StoreClassesTechnician> listClassesTechnician(@Param("scheduleId") Integer scheduleId,
@Param("departmentId") Integer departmentId,
@Param("days") String days);
......
......@@ -74,9 +74,7 @@ public class ScheduleManageController {
@PostMapping("/customer/schedule/submitSchedule")
public JsonResult<Void> submitSchedule(@RequestHeader String token,
@RequestBody SubmitScheduleCommand cmd) {
Integer currentCustomerId = Optional.ofNullable(gogirlTokenService.getByToken(token).getCustomerId())
.orElseThrow(() -> new RRException(500, "token不存在"));
cmd.getScheduleManageDTO().setScheduledUser(currentCustomerId);
cmd.getScheduleManageDTO().setScheduledUser(SessionUtils.getCustomerId());
scheduleManageService.submitSchedule(cmd);
return JsonResult.success();
}
......
......@@ -268,79 +268,7 @@ public class PayController {
String refereeId,
String remark) {
Customer customer = customerService.selectByPhone(phone);
GogirlToken gogirlToken = gogirlTokenService.getByToken(token);
Integer departmentId = gogirlToken.getDepartmentId();
log.info("{} 充值给 {}", gogirlToken.getTechnicianId(), phone);
//新建会员
if (customer == null) {
customer = new Customer();
customer.setStoreRecordRealName(name);
customer.setPhone(phone);
customerService.save(customer);
}
//更新会员的店员记录名字
else if (name != null && !name.isEmpty()) {
customer.setStoreRecordRealName(name);
customerService.updateById(customer);
}
//店铺会员关联
customerDepartmentRelevanceService.insertDepartmentRelevanceIfNotExist(customer.getId(), departmentId, 4, new Date());
//折扣信息
DiscountConfig discountConfig = discountConfigService.selectByCharge((int) (amount * 100));
//会员卡
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>()
.eq(CustomerBalance::getCustomerId, customer.getId()));
//充值类型
Integer type = customerBalance == null ? 2 : 1;
//如果会员卡不存在就新增会员卡
if (customerBalance == null) {
customerBalance = CustomerBalance.getInstance(customer.getId());
customerBalanceMapper.insert(customerBalance);
}
int chargeAmount = (int) (amount * 100);
//充值订单id
String orderId = IdWorker.getIdStr();
//更新余额
customerBalance.setBalance(customerBalance.getBalance() + chargeAmount);
customerBalance.setTotalCharge(customerBalance.getTotalCharge() + chargeAmount);
customerBalance.setUpdateTime(new Date());
//会员等级
customerBalance.setLevel(discountConfig.getLevel());
customerBalanceMapper.updateById(customerBalance);
//充值流水
CustomerBalanceRecord customerBalanceRecord = CustomerBalanceRecord.builder()
.currentBalance(customerBalance.getBalance())
.customerId(customer.getId())
//充送金额由定时任务计算
.bestowAmount(0)
.departmentId(gogirlToken.getDepartmentId())
.departmentName(gogirlToken.getDepartmentName())
.discount(1d)
.orderAmount(chargeAmount)
.orderId(orderId)
//支付方式
.source(source)
.refereeId(refereeId)
.remark(remark)
//订单类型
.type(type)
.time(new Date())
.build();
customerBalanceRecordMapper.insert(customerBalanceRecord);
chargeOrderService.chargeCustomerCard(name, phone, amount, source, refereeId, remark);
return JsonResult.success();
}
}
......@@ -9,7 +9,7 @@ import java.util.List;
public class IdleTimeQuery {
@ApiModelProperty("所有美甲师")
List<StoreTechnicianQuery> storeTechnicianDTOList;
List<StoreTechnicianPeriod> storeTechnicianDTOList;
@ApiModelProperty("时间节点")
List<Long> dateTimeList;
......
......@@ -10,7 +10,7 @@ import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StoreTechnicianQuery implements Serializable {
public class StoreTechnicianPeriod implements Serializable {
/**
* 美甲师的不可用时间段
......@@ -20,7 +20,11 @@ public class StoreTechnicianQuery implements Serializable {
* 美甲师id
*/
private Integer technicianId;
//美甲师姓名
private String name;
private String picturePath;
private String grade;
}
......@@ -16,7 +16,7 @@ public class TreeProgram implements Serializable {
/**
* 节点的美甲师
*/
StoreTechnicianQuery storeTechnicianDTO;
StoreTechnicianPeriod storeTechnicianDTO;
/**
* 节点的服务
......@@ -50,7 +50,7 @@ public class TreeProgram implements Serializable {
* @param scheduleServeQuery 节点服务
* @param parent 父节点
*/
public TreeProgram(StoreTechnicianQuery storeTechnicianDTO, ScheduleServeQuery scheduleServeQuery, TreeProgram parent) {
public TreeProgram(StoreTechnicianPeriod storeTechnicianDTO, ScheduleServeQuery scheduleServeQuery, TreeProgram parent) {
this.storeTechnicianDTO = storeTechnicianDTO;
......
......@@ -8,7 +8,7 @@
left join mall_category mc on mcpr.mall_category_id = mc.id
where true
<if test="param.mallCategoryId!=null">
and t3.id=#{param.mallCategoryId}
and mc.id=#{param.mallCategoryId}
</if>
<if test="param.isHot!=null">
and t1.is_hot=#{param.isHot}
......@@ -17,7 +17,7 @@
and t1.name like concat('%',#{param.searchWord},'%')
</if>
<if test="param.status!=null">
and t1.`status` =param.status
and t1.`status` =#{param.status}
</if>
</select>
</mapper>
\ No newline at end of file
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