Merge branch 'refs/heads/zs' into dev
This commit is contained in:
commit
6686e5da7d
|
|
@ -1,5 +1,6 @@
|
|||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
|
|
@ -80,6 +81,7 @@ public class ShopSongController {
|
|||
* @param songOrderDTO 订单信息
|
||||
* @return result
|
||||
*/
|
||||
@LimitSubmit(key = "song_order_pay:#openId")
|
||||
@PostMapping
|
||||
public Result createOrder(
|
||||
@RequestHeader("openId") String openId,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public interface TbProductMapper {
|
|||
TbProduct selectById(Integer id);
|
||||
|
||||
List<TbProduct> selectByIdIn(@Param("ids") String ids);
|
||||
List<TbProduct> selectByIdInAndCheck(@Param("ids") String ids);
|
||||
|
||||
List<TbProduct> selectByIds(@Param("list") List<String> ids);
|
||||
Integer selectByQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public interface TbShopSongOrderMapper {
|
|||
" LEFT JOIN tb_shop_song AS b ON a.song_id = b.id\n" +
|
||||
" WHERE\n" +
|
||||
" a.open_id = #{openId} and a.shop_id=#{shopId} " +
|
||||
" <if test=\"state!=null\">AND a.state = #{state}</if></script>")
|
||||
" <if test=\"state!=null\">AND a.state = #{state}</if> order by a.state asc, a.create_time desc</script>")
|
||||
List<Map<String, Object>> selectByUserId(@Param("openId") String openId, @Param("state") Integer state, Integer shopId);
|
||||
|
||||
@Select(" SELECT\n" +
|
||||
|
|
@ -61,7 +61,7 @@ public interface TbShopSongOrderMapper {
|
|||
" tb_shop_song_order AS a\n" +
|
||||
" LEFT JOIN tb_shop_song AS b ON a.song_id = b.id\n" +
|
||||
" WHERE\n" +
|
||||
" a.open_id = #{openId} and a.state in (1, 2, 3) and a.shop_id=#{shopId}")
|
||||
" a.open_id = #{openId} and a.state in (1, 2, 3) and a.shop_id=#{shopId} order by a.state asc, a.create_time desc")
|
||||
List<Map<String, Object>> selectActiveOrderByUserId(@Param("openId") String openId, Integer shopId);
|
||||
|
||||
@Select("SELECT a.song_name songName, a.id, b.img FROM `tb_shop_song_order` as a left join tb_shop_song as b on a.song_id=b.id where state=2 limit 1")
|
||||
|
|
|
|||
|
|
@ -59,4 +59,7 @@ public interface RabbitConstants {
|
|||
public static final String CONS_MSG_COLLECT_ROUTINGKEY_PUT = "cons_msg_collect_routingkey_put";
|
||||
|
||||
|
||||
// 库存记录交换机
|
||||
String EXCHANGE_STOCK_RECORD = "exchange.stock.record";
|
||||
String ROUTING_STOCK_RECORD_SALE = "routing.stock.record.sale";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,5 @@ public class RedisCst {
|
|||
// 创建订单锁
|
||||
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
|
||||
public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:";
|
||||
public static final String SONG_PAY_LOCK = "song_pay_lock:";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ public class PayService {
|
|||
TbActivateMapper tbActivateMapper;
|
||||
|
||||
private final TbShopSongOrderService shopSongOrderService;
|
||||
@Autowired
|
||||
private MQUtils mQUtils;
|
||||
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
|
||||
this.shopSongOrderService = shopSongOrderService;
|
||||
|
|
@ -268,7 +270,9 @@ public class PayService {
|
|||
}
|
||||
|
||||
PublicResp<WxScanPayResp> publicResp = thirdPayService.scanpay(thirdUrl, thirdApply.getAppId(),
|
||||
reqbody, reqbody, payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(), "WECHAT", thirdApply.getSmallAppid(), openId, ip, DateUtils.getsdfTimesSS(), thirdApply.getStoreId(), callFSTBack, null, thirdApply.getAppToken());
|
||||
reqbody, reqbody,
|
||||
payment.getAmount().setScale(2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)).longValue(),
|
||||
"WECHAT", thirdApply.getSmallAppid(), openId, ip, DateUtils.getsdfTimesSS(), thirdApply.getStoreId(), callFSTBack, null, thirdApply.getAppToken());
|
||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
if ("000000".equals(publicResp.getCode())) {
|
||||
WxScanPayResp wxScanPayResp = publicResp.getObjData();
|
||||
|
|
@ -878,6 +882,12 @@ public class PayService {
|
|||
producer.printMechine(orderInfo.getId() + "");
|
||||
sendOrderToClient(orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
|
||||
// 发送mq消息并保存库存记录
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("orderId", orderInfo.getId());
|
||||
data.put("plat", "miniApp");
|
||||
mQUtils.sendStockSaleMsg(data);
|
||||
return "SUCCESS";
|
||||
|
||||
}
|
||||
|
|
@ -923,6 +933,12 @@ public class PayService {
|
|||
producer.printCoupons(coupons.toJSONString());
|
||||
sendOrderToClient(orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
|
||||
// 发送mq消息并保存库存记录
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("orderId", orderInfo.getId());
|
||||
data.put("plat", "miniApp");
|
||||
mQUtils.sendStockSaleMsg(data);
|
||||
return "SUCCESS";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,8 @@ public class ProductService {
|
|||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
|
||||
List<TbProduct> products = tbProductMapper.selectByIdIn(in);
|
||||
// List<TbProduct> products = tbProductMapper.selectByIdIn(in);
|
||||
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
|
||||
if (ObjectUtil.isNotEmpty(products) && products.size() > 0) {
|
||||
products.parallelStream().forEach(it -> {
|
||||
Integer sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopSong;
|
|||
import com.chaozhanggui.system.cashierservice.entity.TbShopSongOrder;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.SongOrderDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongOrderService;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopSongService;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQUtils {
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
public MQUtils(RabbitTemplate rabbitTemplate) {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
}
|
||||
|
||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note) {
|
||||
log.info("开始发送{}mq消息, exchange: {}, routingKey: {}, data: {}", note, exchange, routingKey, data);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data));
|
||||
}
|
||||
|
||||
public <T> void sendStockSaleMsg(T data) {
|
||||
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, data, "商品售出增加库存记录");
|
||||
}
|
||||
}
|
||||
|
|
@ -928,6 +928,15 @@
|
|||
order by tb.sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectByIdInAndCheck" resultMap="BaseResultMap">
|
||||
select min( sku.suit ) as suit,tb.*
|
||||
from tb_product tb
|
||||
LEFT JOIN tb_product_sku sku ON tb.id = sku.product_id
|
||||
where tb.id in (${ids}) and is_show_mall =1 and sku.is_del = 0 and sku.is_grounding=1
|
||||
group by tb.id
|
||||
order by tb.sort asc
|
||||
</select>
|
||||
|
||||
<!-- <select id="selectByIdIn" resultMap="BaseResultMap">-->
|
||||
<!-- select *-->
|
||||
<!-- from tb_product-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue