Commit a52e8335 by huluobin

文件上传

parent fe393af7
package com.gogirl.application.order.serve;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gogirl.domain.order.serve.OwnProduce;
/**
* <p>
* 服务类
* </p>
*
* @author robbendev
* @since 2020-05-27
*/
public interface IOwnProduceService extends IService<OwnProduce> {
}
......@@ -230,6 +230,18 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
builder.serveChangePrice(orderServeParam.getServeChangePrice());
}
OrderServe orderServe = builder.build();
//自带款式
if (orderServe.getServeName().trim().equals(ScheduleServe.OWN_PRODUCE_KEY)) {
orderServe.setIsOwnProduce(1);
if (orderServe.getOwnProduceId() == null) {
throw new RRException("请补全自带款式");
}
} else {
orderServe.setIsOwnProduce(2);
orderServe.setOwnProduceId(null);
}
orderServe.calcPrice();
orderServeMapper.insert(orderServe);
......@@ -331,6 +343,18 @@ public class OrderManageServiceImpl extends ServiceImpl<OrderManageMapper, Order
orderServe.setCommentStatus(orderServeParam.getCommentStatus());
//订单服务备注
orderServe.setRemark(orderServeParam.getRemark());
//自带款式
if (orderServe.getServeName().trim().equals(ScheduleServe.OWN_PRODUCE_KEY)) {
orderServe.setIsOwnProduce(1);
if (orderServe.getOwnProduceId() == null) {
throw new RRException("请补全自带款式");
}
} else {
orderServe.setIsOwnProduce(2);
orderServe.setOwnProduceId(null);
}
orderServe.calcPrice();
orderServeMapper.updateById(orderServe);
}
......
package com.gogirl.application.order.serve.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.order.serve.IOwnProduceService;
import com.gogirl.domain.order.serve.OwnProduce;
import com.gogirl.infrastructure.mapper.order.serve.OwnProduceMapper;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author robbendev
* @since 2020-05-27
*/
@Service
public class OwnProduceServiceImpl extends ServiceImpl<OwnProduceMapper, OwnProduce> implements IOwnProduceService {
}
......@@ -603,6 +603,11 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
if (scheduleServe.getMainServeId() != null) {
throw new RRException("不能对辅助服务开单");
}
//如果是自带款式 但是没有设置
if (scheduleServe.getIsOwnProduce() == 1 && scheduleServe.getOwnProduceId() == null) {
throw new RRException("请补全自带款式");
}
//所有需要更新的服务
List<ScheduleServe> updateList = scheduleServeMapper.selectUpdateStatusList(scheduleServe.getSchId(), scheduleServe.getServeId());
......@@ -815,22 +820,15 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
log.error(e.getMessage(), e);
}
// /*3、如果是指定美甲师、判断美甲师是否仍然可用*/
// //构造路径
// List<TreeProgram> treeProgramList = new ArrayList<>();
// TreeProgram treeProgram = new TreeProgram();
// List<ScheduleServe> scheduleServeList = scheduleManage.getListScheduleServer()
// .stream()
// .filter(scheduleServe -> scheduleServe.getServeId() == null)
// .collect(Collectors.toList());
//
// //方案树
// TreeProgram targetTree = idleTimeDTO.getTreeProgram();
//
// boolean isPath = treeProgram.isSubTree(targetTree);
// if (!isPath) {
// throw new RRException("请重新选择美甲师");
// }
}
if (SessionUtils.isSourceFromTechnician()) {
scheduleManage.getListScheduleServer().forEach(
scheduleServe -> {
if (scheduleServe.getIsOwnProduce() == 1 && scheduleServe.getOwnProduceId() == null) {
throw new RRException("请补全自带款式");
}
}
);
}
}
......@@ -924,6 +922,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
scheduleManage.setLastUpdateTime(new Date());
//更次预约
scheduleManageMapper.updateById(scheduleManage);
List<Integer> oldScheduleServeIds = scheduleServeMapper.selectList(new LambdaQueryWrapper<ScheduleServe>().eq(ScheduleServe::getSchId, scheduleManage.getId())).stream().map(ScheduleServe::getId).collect(Collectors.toList());
List<ScheduleServe> scheduleServeList = scheduleManage.getScheduleServeList();
scheduleServeList.forEach(scheduleServe -> scheduleServe.setSchId(scheduleManage.getId()));
......@@ -1339,6 +1338,14 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
scheduleServe.setProduceCurrentPrice(null);
//款式id
scheduleServe.setProduceId(null);
}
//自带款式
if (scheduleServe.getServeName().trim().equals(ScheduleServe.OWN_PRODUCE_KEY)) {
scheduleServe.setIsOwnProduce(1);
} else {
scheduleServe.setIsOwnProduce(2);
scheduleServe.setOwnProduceId(null);
}
//款式做法
scheduleServe.setExplain(baseServe.getExplain());
......@@ -1362,7 +1369,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
return cloneScheduleServe;
})
.collect(Collectors.toList());
//除了第一个 其余的id设空 防止并发请求的幂等
list.stream().skip(1).forEach(var -> var.setId(null));
return list;
})
......
......@@ -235,6 +235,15 @@ public class OrderServe implements Serializable {
@TableField(exist = false)
private String picturePath;
@ApiModelProperty("是否自带款式 1-是 2-否")
private Integer isOwnProduce;
@ApiModelProperty("自带款式id")
@TableField(strategy = FieldStrategy.IGNORED)
private Integer ownProduceId;
@TableField(exist = false)
private OwnProduce ownProduce;
public void addDiscountPrice(BigDecimal discountPrice) {
this.discountPrice = this.discountPrice.add(discountPrice);
......@@ -242,14 +251,13 @@ public class OrderServe implements Serializable {
}
public void calcPrice() {
if (produceId == null) {
if (discountRate == null) {
price = servePrice;
} else {
leisurePrice = servePrice.multiply(discountRate);
price = leisurePrice;
}
} else {
//自带款式
if (ownProduce != null) {
price = ownProduce.getPrice();
}
//预约款式
else if (produceId != null) {
if (discountRate == null) {
//没有活动价格
if (promotionPrice == null) {
......@@ -270,10 +278,20 @@ public class OrderServe implements Serializable {
price = leisurePrice.min(produceCurrentPrice).min(promotionPrice);
}
}
}
//预约服务
else {
if (discountRate == null) {
price = servePrice;
} else {
leisurePrice = servePrice.multiply(discountRate);
price = leisurePrice;
}
}
}
public Boolean isActivity() {
return price.equals(leisurePrice) ||
price.equals(promotionPrice) ||
......
package com.gogirl.domain.order.serve;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020-05-27
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="OwnProduce对象", description="")
public class OwnProduce implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "自带款式名字")
private String name;
@ApiModelProperty(value = "自带款式价格")
private BigDecimal price;
@ApiModelProperty(value = "自带款式时长")
private Integer duration;
}
......@@ -30,6 +30,8 @@ public class ScheduleServe implements Serializable {
*/
private static final long serialVersionUID = 1L;
public static final String OWN_PRODUCE_KEY = "自带款式";
@TableId(type = IdType.AUTO)
@ApiModelProperty("id")
private Integer id;
......@@ -185,16 +187,25 @@ public class ScheduleServe implements Serializable {
private BigDecimal leisurePrice;
@ApiModelProperty("是否自带款式 1-是 2-否")
private Integer isOwnProduce;
@ApiModelProperty("自带款式id")
@TableField(strategy = FieldStrategy.IGNORED)
private Integer ownProduceId;
@TableField(exist = false)
private OwnProduce ownProduce;
public void calcPrice() {
if (produceId == null) {
if (discountRate == null) {
price = servePrice;
} else {
leisurePrice = servePrice.multiply(discountRate);
price = leisurePrice;
}
} else {
//自带款式
if (ownProduce != null) {
price = ownProduce.getPrice();
}
//预约款式
else if (produceId != null) {
if (discountRate == null) {
//没有活动价格
if (promotionPrice == null) {
......@@ -215,8 +226,17 @@ public class ScheduleServe implements Serializable {
price = leisurePrice.min(produceCurrentPrice).min(promotionPrice);
}
}
}
//预约服务
else {
if (discountRate == null) {
price = servePrice;
} else {
leisurePrice = servePrice.multiply(discountRate);
price = leisurePrice;
}
}
}
public Boolean isActivity() {
......
package com.gogirl.infrastructure.mapper.order.serve;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gogirl.domain.order.serve.OwnProduce;
/**
* <p>
* Mapper 接口
* </p>
*
* @author robbendev
* @since 2020-05-27
*/
public interface OwnProduceMapper extends BaseMapper<OwnProduce> {
}
......@@ -4,9 +4,12 @@ package com.gogirl.infrastructure.mapper.product.serve;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gogirl.domain.product.serve.BaseProduce;
import com.gogirl.shared.product.CalcServiceDuration;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by yinyong on 2018/8/23.
*/
......@@ -47,4 +50,6 @@ public interface BaseProduceMapper extends BaseMapper<BaseProduce> {
* 同步款式销量
*/
void syncSalesNum();
List<CalcServiceDuration> queryProduceServiceDuration();
}
package com.gogirl.interfaces.order.serve;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author robbendev
* @since 2020-05-27
*/
@RestController
@RequestMapping("/own-produce")
public class OwnProduceController {
}
......@@ -24,12 +24,12 @@ public class FileController {
@ApiOperation(value = "图片上传")
@PostMapping("/customer/xcx/upload")
public JsonResult<String> upload(MultipartFile multipartFile) throws Exception {
if (multipartFile == null) {
public JsonResult<String> upload(MultipartFile file) throws Exception {
if (file == null) {
throw new RRException("上传内容为空");
}
log.info("图片上传");
String imgUrl = fileService.saveImage(multipartFile);
String imgUrl = fileService.saveImage(file);
return JsonResult.success(imgUrl);
}
......
package com.gogirl.shared.product;
import lombok.Data;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/5/26 5:47 下午
*/
@Data
public class CalcServiceDuration {
private Integer id;
private Integer quantity;
private Integer duration;
}
spring:
profiles:
active: prod
active: pre
servlet:
#文件上传最大容量
multipart:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gogirl.infrastructure.mapper.order.serve.OwnProduceMapper">
</mapper>
......@@ -127,6 +127,12 @@
</otherwise>
</choose>
</select>
<select id="queryProduceServiceDuration" resultType="com.gogirl.shared.product.CalcServiceDuration">
SELECT t1.bargain_price,t1.`name` ,t1.service_duration ,t1.id,t2.quantity,t3.price,t3.duration from base_produce t1
LEFT JOIN produce_technique_sku t2 on t1.id= t2.produce_id
LEFT JOIN technique_sku t3 on t2.technique_sku_id = t3.id
where t3.duration is not null
</select>
</mapper>
......@@ -19,6 +19,7 @@ import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.order.serve.OrderServe;
import com.gogirl.domain.product.purchase.PurchaseStock;
import com.gogirl.domain.product.purchase.PurchaseStockRecord;
import com.gogirl.domain.product.serve.BaseProduce;
import com.gogirl.domain.store.complaint.ComplaintDetailed;
import com.gogirl.domain.store.complaint.ComplaintDetailedTechnician;
import com.gogirl.domain.store.complaint.ComplaintMain;
......@@ -43,6 +44,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import com.gogirl.infrastructure.mapper.product.purchase.PurchaseSkuMapper;
import com.gogirl.infrastructure.mapper.product.purchase.PurchaseStockMapper;
import com.gogirl.infrastructure.mapper.product.purchase.PurchaseStockRecordMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseProduceMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintDetailedTechnicianMapper;
import com.gogirl.infrastructure.mapper.store.complaint.ComplaintMainMapper;
......@@ -55,6 +57,7 @@ import com.gogirl.infrastructure.mapper.xcx.TimeNodeMapper;
import com.gogirl.infrastructure.mapper.xcx.WeekConfigMapper;
import com.gogirl.infrastructure.schedule.Schedule;
import com.gogirl.infrastructure.service.mail.MailService;
import com.gogirl.shared.product.CalcServiceDuration;
import com.gogirl.shared.product.PurchaseSkuPOI;
import lombok.extern.slf4j.Slf4j;
import org.assertj.core.util.Lists;
......@@ -695,4 +698,23 @@ public class Test {
EasyExcel.write(fileName, PurchaseSkuPOI.class).sheet("purchaseSku").doWrite(purchaseSkuPOIList);
}
@Resource
BaseProduceMapper baseProduceMapper;
@org.junit.Test
public void syncProduceServiceDuration() {
List<CalcServiceDuration> calcServiceDurationList = baseProduceMapper.queryProduceServiceDuration();
calcServiceDurationList.stream().collect(Collectors.groupingBy(CalcServiceDuration::getId))
.forEach((key, value) -> {
BaseProduce baseProduce = baseProduceMapper.selectById(key);
Integer sumServiceDuration = value.stream().map(calcServiceDuration -> calcServiceDuration.getDuration() * calcServiceDuration.getQuantity()).mapToInt(Integer::intValue).sum();
baseProduce.setServiceDuration(sumServiceDuration);
baseProduceMapper.updateById(baseProduce);
});
}
}
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