Commit 241b65e1 by huluobin

限时特价

parent 6e1b336b
......@@ -22,8 +22,11 @@ public class ProducePromotionTime implements Serializable {
@TableId(type = IdType.AUTO)
private Integer id;
private Integer produceId;
private Date startTime;
private Date endTime;
@ApiModelProperty("活动价格")
......
......@@ -9,9 +9,36 @@ import java.util.List;
public interface BaseFeaturesMapper extends BaseMapper<BaseFeatures> {
/**
* <p>
* 查询款式的标签列表
* </p>
*
* @param serveTypeId
* @return
*/
List<BaseFeatures> queryProduceFeatures(@Param("serveTypeId") Integer serveTypeId);
/**
* <p>
* 查询服务的标签列表
* </p>
*
* @param serveTypeId
* @return
*/
List<BaseFeatures> queryServeFeatures(@Param("serveTypeId") Integer serveTypeId);
/**
* <p>
* 查询指定款式对应的首页标签列表
*
* </p>
*
* @param id
* @return
*/
List<BaseFeatures> queryProduceFeaturesById(Integer id);
}
......@@ -7,5 +7,6 @@ import org.apache.ibatis.annotations.Param;
public interface ProducePromotionTimeMapper extends BaseMapper<ProducePromotionTime> {
ProducePromotionTime queryByProduceId(@Param("produceId") Integer produceId, @Param("localDateTime") String localDateTime);
}
......@@ -13,6 +13,7 @@ import com.gogirl.domain.common.xcx.WeekConfig;
import com.gogirl.domain.market.timescard.TimesCardCustomerRelevance;
import com.gogirl.domain.order.mall.MallOrder;
import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.order.serve.ProducePromotionTime;
import com.gogirl.domain.order.serve.ScheduleManage;
import com.gogirl.domain.order.serve.ScheduleServe;
import com.gogirl.domain.product.mall.MallCategory;
......@@ -40,10 +41,7 @@ import com.gogirl.infrastructure.mapper.order.serve.OrderServeMapper;
import com.gogirl.infrastructure.mapper.order.serve.ScheduleManageMapper;
import com.gogirl.infrastructure.mapper.product.mall.MallCategoryMapper;
import com.gogirl.infrastructure.mapper.product.mall.MallProductMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseFeaturesMapper;
import com.gogirl.infrastructure.mapper.product.serve.BaseProduceMapper;
import com.gogirl.infrastructure.mapper.product.serve.FeaturesMappingMapper;
import com.gogirl.infrastructure.mapper.product.serve.ProduceSalesMapper;
import com.gogirl.infrastructure.mapper.product.serve.*;
import com.gogirl.infrastructure.mapper.store.career.CareerMapper;
import com.gogirl.infrastructure.mapper.store.store.StoreDataMapper;
import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper;
......@@ -66,13 +64,16 @@ import org.springframework.http.MediaType;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -747,4 +748,60 @@ public class Schedule {
couponCustomerRelevanceDao.syncCouponCustomerRelDiscountPercent();
log.info("每分钟同步卡券折扣信息 结束");
}
@Resource
ProducePromotionTimeMapper producePromotionTimeMapper;
/**
* 每分钟同步款式的现价和限制特价标签
*/
@Transactional
@Scheduled(cron = "0 0/2 * * * ?")
public void syncProducePriceAndLabel() {
baseProduceMapper.selectList(new LambdaQueryWrapper<>())
.forEach(baseProduce -> {
ProducePromotionTime producePromotionTime = producePromotionTimeMapper.queryByProduceId(baseProduce.getId(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()));
//先删除热销标签
//款式的所有标签
List<BaseFeatures> baseFeaturesList = baseFeaturesMapper.queryProduceFeaturesById(baseProduce.getId());
BaseFeatures specItem = ListUtil.getOne(baseFeaturesList, BaseFeatures::getName, "限时特价");
if (specItem != null) {
featuresMappingMapper.delete(new LambdaQueryWrapper<FeaturesMapping>()
.eq(FeaturesMapping::getDataId, baseProduce.getId())
.eq(FeaturesMapping::getFeaturesId, specItem.getId()));
}
//如果不是限时特价
if (producePromotionTime == null) {
baseProduce.setCurrentPrice(baseProduce.getBargainPrice());
baseProduceMapper.updateById(baseProduce);
}
//如果是限时
else {
baseProduce.setCurrentPrice(producePromotionTime.getPrice());
baseProduceMapper.updateById(baseProduce);
BaseFeatures baseFeatures = baseFeaturesMapper.selectOne(new LambdaQueryWrapper<BaseFeatures>()
.eq(BaseFeatures::getName, "限时特价"));
if (baseFeatures != null) {
//如果存在限时特价标签 就为该款式打上标签
FeaturesMapping featuresMapping = new FeaturesMapping();
featuresMapping.setDataId(baseProduce.getId());
featuresMapping.setDataType(2);
featuresMapping.setFeaturesId(baseFeatures.getId());
featuresMappingMapper.insert(featuresMapping);
}
}
});
}
}
......@@ -29,6 +29,17 @@ public class CustomerController {
@Resource
private GogirlTokenService gogirlTokenService;
@LoginIgnore
@AuthIgnore
@ApiOperation(value = "小程序用户登录")
@GetMapping("/customer/xcx/login")
public JsonResult<String> login(@RequestParam String code) {
String token = customerService.login(code);
return JsonResult.success(token);
}
@ApiOperation("用户授权接街道地址信息")
@GetMapping("/customer/xcx/bindAddressInfo")
public JsonResult<String> bindAddressInfo(@RequestParam Integer customerId,
......@@ -40,14 +51,6 @@ public class CustomerController {
return JsonResult.success();
}
@LoginIgnore
@AuthIgnore
@ApiOperation(value = "小程序用户登录")
@GetMapping("/customer/xcx/login")
public JsonResult<String> login(@RequestParam String code) {
String token = customerService.login(code);
return JsonResult.success(token);
}
@LoginIgnore
@AuthIgnore
......@@ -60,6 +63,19 @@ public class CustomerController {
return JsonResult.success(customer);
}
@AuthIgnore
@LoginIgnore
@ApiOperation(value = "客户授权手机号码")
@PostMapping("/customer/xcx/authorizedPhone")
public JsonResult<Customer> authorizedPhone(@RequestHeader String token,
@RequestParam String encryptedData,
@RequestParam String iv) throws InvalidAlgorithmParameterException {
Customer customer = customerService.authorizedPhone(token, encryptedData, iv);
return JsonResult.success(customer);
}
@ApiOperation(value = "h5用户登录")
@GetMapping("/customer/no_h5Login")
public JsonResult<String> h5Login(@RequestParam Integer orderId) {
......@@ -76,16 +92,7 @@ public class CustomerController {
}
@AuthIgnore
@LoginIgnore
@ApiOperation(value = "客户授权手机号码")
@PostMapping("/customer/xcx/authorizedPhone")
public JsonResult<Customer> authorizedPhone(@RequestHeader String token,
@RequestParam String encryptedData,
@RequestParam String iv) throws InvalidAlgorithmParameterException {
Customer customer = customerService.authorizedPhone(token, encryptedData, iv);
return JsonResult.success(customer);
}
@AuthIgnore
@ApiOperation(value = "客户根据token获取用户信息")
......
......@@ -35,4 +35,12 @@
and t.has_index_show = 1
order by index_sort ASC
</select>
</mapper>
\ No newline at end of file
<select id="queryProduceFeaturesById" resultType="com.gogirl.domain.product.serve.BaseFeatures">
SELECT *
from base_produce t1
LEFT JOIN features_mapping t2 on t1.id = t2.data_id and t2.data_type = 2
LEFT JOIN base_features t3 on t2.features_id = t3.id
where t1.id = #{id}
</select>
</mapper>
<?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.product.serve.ProducePromotionTimeMapper">
<select id="queryByProduceId" resultType="com.gogirl.domain.order.serve.ProducePromotionTime">
SELECT *
from produce_promotion_time
where produce_id = #{produceId}
and start_time &lt;= #{localDateTime}
and end_time &gt;= #{localDateTime}
limit 1
</select>
</mapper>
\ No newline at end of file
</mapper>
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