Commit 11c97e9c authored by wp's avatar wp

Merge branch 'dev' of https://gitlab.33.cn/yimu/mall-server into dev

# Conflicts: # mall-sql/mall_create.sql
parents 8e8ae265 5d59b8e3
...@@ -158,4 +158,10 @@ public interface UserAssetMapper extends BaseMapper<UserAsset> { ...@@ -158,4 +158,10 @@ public interface UserAssetMapper extends BaseMapper<UserAsset> {
@Select("select * from user_asset where uid = #{uid} and coin = #{coin}") @Select("select * from user_asset where uid = #{uid} and coin = #{coin}")
UserAsset getCoin(@Param("uid") String uid, @Param("coin") String value); UserAsset getCoin(@Param("uid") String uid, @Param("coin") String value);
@Update("update user_asset set amount = amount -#{number},frozen = frozen + #{number},update_time = #{time} where id = #{id} and update_time = #{updateTime} and amount >= #{number}")
int useToFrozen(@Param("id") Long id,
@Param("number") BigDecimal number,
@Param("updateTime") Long updateTime,
@Param("time") long currentTimeMillis);
} }
...@@ -49,4 +49,6 @@ public class OrderDetailVO { ...@@ -49,4 +49,6 @@ public class OrderDetailVO {
private Integer type; private Integer type;
@ApiModelProperty("预售商品信息") @ApiModelProperty("预售商品信息")
private PreSale preSale; private PreSale preSale;
@ApiModelProperty(value = "(销售方式)1.普通 4.盲盒")
private Integer salesType;
} }
...@@ -156,4 +156,7 @@ public interface IUserAssetService extends IService<UserAsset> { ...@@ -156,4 +156,7 @@ public interface IUserAssetService extends IService<UserAsset> {
int addReward(String uid, String commentId, BigDecimal evaluationRefund); int addReward(String uid, String commentId, BigDecimal evaluationRefund);
int deleteAmount(Long id, BigDecimal amount); int deleteAmount(Long id, BigDecimal amount);
//可用变冻结
int useToFrozen(Long id, BigDecimal number, Long updateTime, long currentTimeMillis);
} }
...@@ -578,4 +578,9 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset ...@@ -578,4 +578,9 @@ public class UserAssetServiceImpl extends ServiceImpl<UserAssetMapper, UserAsset
public int deleteAmount(Long id, BigDecimal amount) { public int deleteAmount(Long id, BigDecimal amount) {
return coinDao.deleteAmount(id, amount); return coinDao.deleteAmount(id, amount);
} }
@Override
public int useToFrozen(Long id, BigDecimal number, Long updateTime, long currentTimeMillis) {
return coinDao.useToFrozen(id, number, updateTime, currentTimeMillis);
}
} }
package com.fzm.mall.server.front.constant; package com.fzm.mall.server.front.constant;
import java.math.BigDecimal;
public class CommonConst { public class CommonConst {
public static final String USER = "user"; public static final String USER = "user";
public static final String SIGNATURE = "signature"; public static final String SIGNATURE = "signature";
public static final String NONCE = "nonce"; public static final String NONCE = "nonce";
public static final BigDecimal NEGATIVE_ONE = new BigDecimal("-1");
/**
* a = b
*/
public static final int BIEDICIMAL_EQUAL_RESULT = 0;
/**
* a < b
*/
public static final int BIEDICIMAL_LEFT_LESS = -1;
/**
* a > b
*/
public static final int BIEDICIMAL_LEFT_GREATER = 1;
public CommonConst() { public CommonConst() {
} }
} }
package com.fzm.mall.server.front.constant; package com.fzm.mall.server.front.constant;
import java.math.BigDecimal;
/** /**
* @author tdz * @author tdz
* @date 2021/03/02 14:51 * @date 2021/03/02 14:51
...@@ -16,4 +18,15 @@ public class GoodMainConst { ...@@ -16,4 +18,15 @@ public class GoodMainConst {
*/ */
public final static String ORDER_BY_CART = "1"; public final static String ORDER_BY_CART = "1";
/**
* 盲盒商品单次下单的购买数量:一次只能买一个
*/
public final static Integer BLIND_BOX_ORDER_SKU_NUM = 1;
public final static BigDecimal BLIND_BOX_ORDER_SKU_NUM_BIGDECIMAL = new BigDecimal("1");
/**
* 盲盒商品的待支付订单回显规格属性值的默认值
*/
public final static String DEFAULT_PROP_VALUE = "默认";
} }
...@@ -68,6 +68,8 @@ public enum MallResponseEnum { ...@@ -68,6 +68,8 @@ public enum MallResponseEnum {
NOT_SUPPORT_BUY_MYSELF("200221","NOT_SUPPORT_BUY_MYSELF"), NOT_SUPPORT_BUY_MYSELF("200221","NOT_SUPPORT_BUY_MYSELF"),
ONLY_SUPPORT_MAIL("200222","ONLY_SUPPORT_MAIL"), ONLY_SUPPORT_MAIL("200222","ONLY_SUPPORT_MAIL"),
SEND_CODE_ERR("200223","SEND_CODE_ERR"), SEND_CODE_ERR("200223","SEND_CODE_ERR"),
HOT_ACTIVITY("200237","HOT_ACTIVITY"),
// 系统参数配置 // 系统参数配置
QUERY_SUCCESS("200200", "query_success"), QUERY_SUCCESS("200200", "query_success"),
......
package com.fzm.mall.server.front.enums;
public enum AssetRecordTypeEnum {
//积分充值
INTEGRAL_RECHARGE(7),
//积分抵扣
INTEGRAL_DEDUCTION(9),
//退款
RETURN_MONEY(10),
//商品币购买
BUY_GOODS(11),
//扣除积分
DEDUCT_INTEGRAL(17),
//提货
DRAW_GOODS(18),
//评论奖励
COMMENT_REWARD(19),
//转赠-转入
PRESENT_IN(20),
//转赠—转出
PRESENT_OUT(21),
//注册奖励
REGISTER_REWARD(22),
//外部token转入
OUT_TOKEN_IN(23),
//外部NFT转入
OUT_NFT_IN(24),
//向外划转
TRANSFER_OUT(25),
//退货
RETURN_GOODS(26),
//邀请注册奖励
INVITE_REGISTER_REWARD(27),
//发布转让
RELEASE_TRANSFER(28),
//商品币退还
GOODS_COIN_REFUND(29),
//积分抵扣退还
INTEGRAL_DEDUCTION_RETURN(30),
//31.slg数字资产发行 32.slg数字资产增发 33.slg数字资产减发 34.slg数字资产回收 35.slc防伪NFT转入
//物物交换转让转入
BARTER_TRANSFER_IN(36),
//物物交换转让转出
BARTER_TRANSFER_OUT(37),
;
private Integer type;
AssetRecordTypeEnum(Integer type){
this.type = type;
}
public Integer getType() {
return type;
}
}
package com.fzm.mall.server.front.enums;
public enum GoodSpuSalesTypeEnum {
/**
* 普通商品
*/
GENERAL(1),
/**
* 盲盒商品
*/
BLIND_BOX(4),
;
private Integer type;
GoodSpuSalesTypeEnum(Integer type){
this.type = type;
}
public Integer getType() {
return type;
}
}
package com.fzm.mall.server.front.enums;
public enum OrderPayStateEnum {
/**
* 6->待付款
*/
PAY_STATE_TO_PAY(6),
;
private Integer state;
OrderPayStateEnum(Integer state){
this.state = state;
}
public Integer getState() {
return state;
}
}
package com.fzm.mall.server.front.enums;
public enum OrderPayTypeEnum {
//积分支付
INTEGRAL(4),
;
private Integer type;
OrderPayTypeEnum(Integer type){
this.type = type;
}
public Integer getType() {
return type;
}
}
package com.fzm.mall.server.front.enums;
public enum OrderStateEnum {
/**
* 7->待支付
*/
ORDER_STATE_TO_PAY(7),
;
private Integer state;
OrderStateEnum(Integer state){
this.state = state;
}
public Integer getState() {
return state;
}
}
package com.fzm.mall.server.front.enums;
public enum OrderTypeEnum {
/**
* 普通商品
*/
GENERAL(1),
;
private Integer type;
OrderTypeEnum(Integer type){
this.type = type;
}
public Integer getType() {
return type;
}
}
...@@ -236,16 +236,6 @@ public class GoodsController { ...@@ -236,16 +236,6 @@ public class GoodsController {
} }
public static void main(String[] args) {
List<String> list = new ArrayList<>();
list.add("key");
list.add("111");
String str = StringUtils.join("\',\'", list);
String str2 = "(\'" + str + "\')";
System.out.println(str2);
}
/* @ApiOperation(value = "商品评论 参数:goodsId") /* @ApiOperation(value = "商品评论 参数:goodsId")
@PostMapping("/without/getComment") @PostMapping("/without/getComment")
public ResponseVO<Comment> getComment(@RequestBody JSONObject data,@RequestBody PageVo pageVo){ public ResponseVO<Comment> getComment(@RequestBody JSONObject data,@RequestBody PageVo pageVo){
......
...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.goods.mapper; ...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.goods.mapper;
import com.fzm.mall.server.front.goods.model.DistributionTemplateItem; import com.fzm.mall.server.front.goods.model.DistributionTemplateItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
...@@ -13,6 +14,7 @@ import org.apache.ibatis.annotations.Select; ...@@ -13,6 +14,7 @@ import org.apache.ibatis.annotations.Select;
* @author fzm * @author fzm
* @since 2021-03-19 * @since 2021-03-19
*/ */
@Mapper
public interface DistributionTemplateItemMapper extends BaseMapper<DistributionTemplateItem> { public interface DistributionTemplateItemMapper extends BaseMapper<DistributionTemplateItem> {
@Select("select * from distribution_template_item where template_id = #{templateId} and delivery_area like #{province}") @Select("select * from distribution_template_item where template_id = #{templateId} and delivery_area like #{province}")
DistributionTemplateItem getByTemplateIdAndProvince(@Param("templateId") String templateId, @Param("province") String province); DistributionTemplateItem getByTemplateIdAndProvince(@Param("templateId") String templateId, @Param("province") String province);
......
...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.goods.mapper; ...@@ -2,6 +2,7 @@ package com.fzm.mall.server.front.goods.mapper;
import com.fzm.mall.server.front.goods.model.DistributionTemplate; import com.fzm.mall.server.front.goods.model.DistributionTemplate;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/** /**
* <p> * <p>
...@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author fzm * @author fzm
* @since 2021-03-19 * @since 2021-03-19
*/ */
@Mapper
public interface DistributionTemplateMapper extends BaseMapper<DistributionTemplate> { public interface DistributionTemplateMapper extends BaseMapper<DistributionTemplate> {
} }
...@@ -66,8 +66,8 @@ public interface GoodSkuMapper extends BaseMapper<GoodSku> { ...@@ -66,8 +66,8 @@ public interface GoodSkuMapper extends BaseMapper<GoodSku> {
@Select("select a.merchant_id as merchantId,a.template_id as templateId,a.name as name,a.goods_id as goodsId,b.* from goods_spu a left join goods_sku b on a.goods_id = b.goods_id where b.sku_id = #{skuId}") @Select("select a.merchant_id as merchantId,a.template_id as templateId,a.name as name,a.goods_id as goodsId,b.* from goods_spu a left join goods_sku b on a.goods_id = b.goods_id where b.sku_id = #{skuId}")
SkuVo getSkuVoBySkuId(@Param("skuId") String skuId); SkuVo getSkuVoBySkuId(@Param("skuId") String skuId);
@Update("update goods_sku set stock =stock - #{num} where sku_id = #{skuId} and stock >= #{num}") // @Update("update goods_sku set stock =stock - #{num} where sku_id = #{skuId} and stock >= #{num}")
int delStock(@Param("skuId") String skuId, @Param("num") Integer num); // int delStock(@Param("skuId") String skuId, @Param("num") Integer num);
@Update("update goods_sku set stock =stock + #{num} where sku_id = #{skuId}") @Update("update goods_sku set stock =stock + #{num} where sku_id = #{skuId}")
void addStock(@Param("skuId") String skuId, @Param("num") Integer number); void addStock(@Param("skuId") String skuId, @Param("num") Integer number);
...@@ -84,4 +84,12 @@ public interface GoodSkuMapper extends BaseMapper<GoodSku> { ...@@ -84,4 +84,12 @@ public interface GoodSkuMapper extends BaseMapper<GoodSku> {
String getGoodsName(@Param("goodsId") String goodsId); String getGoodsName(@Param("goodsId") String goodsId);
SaleHotVo count(String goodsId); SaleHotVo count(String goodsId);
/**
* 获取库存大于0的sku列表
*/
List<SkuVo> listAvailableSku(@Param("goodsId") String goodsId);
int delStock(@Param("skuId") String skuId,
@Param("num") Integer num);
} }
...@@ -144,6 +144,9 @@ public class GoodSpu implements Serializable { ...@@ -144,6 +144,9 @@ public class GoodSpu implements Serializable {
@ApiModelProperty(value = "溯源hash") @ApiModelProperty(value = "溯源hash")
private String hash; private String hash;
@ApiModelProperty(value = "(销售方式)1.普通 4.盲盒")
private Integer salesType;
public void initTokenId() { public void initTokenId() {
if (commodityPass.equals(COMMODITY_PASS_OUT)){ if (commodityPass.equals(COMMODITY_PASS_OUT)){
setTokenId(Long.valueOf(tokenIdStr)); setTokenId(Long.valueOf(tokenIdStr));
......
...@@ -55,7 +55,4 @@ public class OprationFunction implements Serializable { ...@@ -55,7 +55,4 @@ public class OprationFunction implements Serializable {
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT_UPDATE)
private Long updateTime; private Long updateTime;
private String param;
} }
package com.fzm.mall.server.front.goods.model.vo; package com.fzm.mall.server.front.goods.model.vo;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fzm.mall.server.front.goods.model.MarketingCoupon;
import com.fzm.mall.server.front.goods.model.Nft; import com.fzm.mall.server.front.goods.model.Nft;
import com.fzm.mall.server.front.goods.model.Sku;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
...@@ -80,4 +76,10 @@ public class GoodsVo { ...@@ -80,4 +76,10 @@ public class GoodsVo {
private String nftFile; private String nftFile;
private String hash; private String hash;
@ApiModelProperty(value = "(销售方式)1.普通 4.盲盒")
private Integer salesType;
@ApiModelProperty(value = "盲盒规则")
private String blindBoxRule;
} }
...@@ -39,4 +39,7 @@ public class SaleHotVo { ...@@ -39,4 +39,7 @@ public class SaleHotVo {
@ApiModelProperty(value = "商品发行量总量") @ApiModelProperty(value = "商品发行量总量")
private Integer circulationCount; private Integer circulationCount;
@ApiModelProperty(value = "(销售方式)1.普通 4.盲盒")
private Integer salesType;
} }
...@@ -66,4 +66,12 @@ public class SkuVo { ...@@ -66,4 +66,12 @@ public class SkuVo {
private String commodityPassId; private String commodityPassId;
@ApiModelProperty(value = "盲盒商品的销售难度系数(1-10)")
private Integer difficulty;
@ApiModelProperty(value = "盲盒商品的规格是否为隐藏款")
private Boolean isHide;
@ApiModelProperty(value = "盲盒商品价格")
private BigDecimal blindBoxprice;
} }
...@@ -19,7 +19,7 @@ public interface IDistributionTemplateService extends IService<DistributionTempl ...@@ -19,7 +19,7 @@ public interface IDistributionTemplateService extends IService<DistributionTempl
DistributionTemplate getTemplateId(String templateId); DistributionTemplate getTemplateId(String templateId);
BigDecimal getPrice(String templateId, String province, BigDecimal bigDecimal, Integer integer, BigDecimal bigDecimal1); BigDecimal getPrice(String templateId, String province, BigDecimal postFeeTotal, Integer merchantGoodSize, BigDecimal merchantGoodWeight);
DistributionTemplate getByMerchantId(String merchantId); DistributionTemplate getByMerchantId(String merchantId);
} }
...@@ -15,7 +15,10 @@ import java.util.Map; ...@@ -15,7 +15,10 @@ import java.util.Map;
* @since 2021-03-02 * @since 2021-03-02
*/ */
public interface IGoodSkuPropService extends IService<GoodSkuProp> { public interface IGoodSkuPropService extends IService<GoodSkuProp> {
List<Map<String, Object>> getSkuPropListBySkuId (String skuId); List<Map<String, Object>> getSkuPropListBySkuId (String skuId);
List<GoodSkuProp> getList(String string); List<GoodSkuProp> getList(String string);
void delSkuProCachByOid(String oid);
} }
package com.fzm.mall.server.front.goods.service.impl; package com.fzm.mall.server.front.goods.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.enums.SqlLike;
import com.fzm.mall.server.front.goods.mapper.DistributionTemplateItemMapper; import com.fzm.mall.server.front.goods.mapper.DistributionTemplateItemMapper;
import com.fzm.mall.server.front.goods.model.DistributionTemplate; import com.fzm.mall.server.front.goods.model.DistributionTemplate;
import com.fzm.mall.server.front.goods.mapper.DistributionTemplateMapper; import com.fzm.mall.server.front.goods.mapper.DistributionTemplateMapper;
...@@ -28,9 +26,6 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem ...@@ -28,9 +26,6 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem
@Autowired @Autowired
private DistributionTemplateItemMapper distributionTemplateItemMapper; private DistributionTemplateItemMapper distributionTemplateItemMapper;
@Autowired
private DistributionTemplateMapper distributionTemplateMapper;
@Override @Override
public DistributionTemplate getTemplateId(String templateId) { public DistributionTemplate getTemplateId(String templateId) {
QueryWrapper<DistributionTemplate> q = new QueryWrapper<>(); QueryWrapper<DistributionTemplate> q = new QueryWrapper<>();
...@@ -39,7 +34,7 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem ...@@ -39,7 +34,7 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem
} }
@Override @Override
public BigDecimal getPrice(String templateId, String province, BigDecimal bigDecimal,Integer size,BigDecimal weight) { public BigDecimal getPrice(String templateId, String province, BigDecimal postFeeTotal,Integer size,BigDecimal weight) {
province = "%"+province+"%"; province = "%"+province+"%";
DistributionTemplateItem distributionTemplateItem = distributionTemplateItemMapper.getByTemplateIdAndProvince(templateId,province); DistributionTemplateItem distributionTemplateItem = distributionTemplateItemMapper.getByTemplateIdAndProvince(templateId,province);
if(distributionTemplateItem == null){ if(distributionTemplateItem == null){
...@@ -55,7 +50,7 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem ...@@ -55,7 +50,7 @@ public class DistributionTemplateServiceImpl extends ServiceImpl<DistributionTem
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
}else if(distributionTemplateItem.getPricingType()==3){ }else if(distributionTemplateItem.getPricingType()==3){
if(distributionTemplateItem.getFreeShippingAmount().compareTo(bigDecimal)==1){ if(distributionTemplateItem.getFreeShippingAmount().compareTo(postFeeTotal)==1){
return getBigDecimal(templateId, size, weight); return getBigDecimal(templateId, size, weight);
}else{ }else{
return BigDecimal.ZERO; return BigDecimal.ZERO;
......
...@@ -2,14 +2,18 @@ package com.fzm.mall.server.front.goods.service.impl; ...@@ -2,14 +2,18 @@ package com.fzm.mall.server.front.goods.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzm.mall.server.front.constant.GoodMainConst;
import com.fzm.mall.server.front.goods.model.GoodSkuProp; import com.fzm.mall.server.front.goods.model.GoodSkuProp;
import com.fzm.mall.server.front.goods.mapper.GoodSkuPropMapper; import com.fzm.mall.server.front.goods.mapper.GoodSkuPropMapper;
import com.fzm.mall.server.front.goods.service.IGoodSkuPropService; import com.fzm.mall.server.front.goods.service.IGoodSkuPropService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.mall.server.front.order.mapper.OrderDetailMapper;
import com.fzm.mall.server.front.order.model.OrderDetail;
import com.fzm.mall.server.front.redis.GoodRedis; import com.fzm.mall.server.front.redis.GoodRedis;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -28,6 +32,7 @@ import java.util.Map; ...@@ -28,6 +32,7 @@ import java.util.Map;
@RequiredArgsConstructor(onConstructor = @__(@Autowired)) @RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodSkuProp> implements IGoodSkuPropService { public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodSkuProp> implements IGoodSkuPropService {
private final GoodRedis goodRedis; private final GoodRedis goodRedis;
private final OrderDetailMapper orderDetailMapper;
public static void main(String[] args) { public static void main(String[] args) {
List<Map<String, Object>> skuProp = new ArrayList<>(); List<Map<String, Object>> skuProp = new ArrayList<>();
...@@ -38,6 +43,7 @@ public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodS ...@@ -38,6 +43,7 @@ public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodS
System.out.println(skuProp); System.out.println(skuProp);
} }
@Override
public List<Map<String, Object>> getSkuPropListBySkuId(String skuId) { public List<Map<String, Object>> getSkuPropListBySkuId(String skuId) {
List<Map<String, Object>> skuProp = goodRedis.getSkuProp(skuId); List<Map<String, Object>> skuProp = goodRedis.getSkuProp(skuId);
if (skuProp != null) { if (skuProp != null) {
...@@ -61,11 +67,22 @@ public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodS ...@@ -61,11 +67,22 @@ public class GoodSkuPropServiceImpl extends ServiceImpl<GoodSkuPropMapper, GoodS
return skuProp; return skuProp;
} }
@Override @Override
public List<GoodSkuProp> getList(String string) { public List<GoodSkuProp> getList(String string) {
QueryWrapper<GoodSkuProp> queryWrapper = new QueryWrapper<>(); QueryWrapper<GoodSkuProp> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("sku_id", string); queryWrapper.eq("sku_id", string);
return list(queryWrapper); return list(queryWrapper);
} }
@Override
public void delSkuProCachByOid(String oid) {
QueryWrapper<OrderDetail> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("oid", oid);
List<OrderDetail> detailList = orderDetailMapper.selectList(queryWrapper);
if(!CollectionUtils.isEmpty(detailList)){
detailList.forEach(orderDetail -> {
goodRedis.delSkuProp(orderDetail.getSkuId());
});
}
}
} }
...@@ -2,6 +2,10 @@ package com.fzm.mall.server.front.merchant.mapper; ...@@ -2,6 +2,10 @@ package com.fzm.mall.server.front.merchant.mapper;
import com.fzm.mall.server.front.merchant.model.Merchant; import com.fzm.mall.server.front.merchant.model.Merchant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
/** /**
* <p> * <p>
...@@ -11,6 +15,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -11,6 +15,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author fzm * @author fzm
* @since 2021-03-02 * @since 2021-03-02
*/ */
@Mapper
public interface MerchantMapper extends BaseMapper<Merchant> { public interface MerchantMapper extends BaseMapper<Merchant> {
BigDecimal getPrice(@Param("coin") String coin);
} }
...@@ -3,6 +3,8 @@ package com.fzm.mall.server.front.merchant.service; ...@@ -3,6 +3,8 @@ package com.fzm.mall.server.front.merchant.service;
import com.fzm.mall.server.front.merchant.model.Merchant; import com.fzm.mall.server.front.merchant.model.Merchant;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
/** /**
* <p> * <p>
* 服务类 * 服务类
...@@ -12,6 +14,9 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -12,6 +14,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @since 2021-03-02 * @since 2021-03-02
*/ */
public interface IMerchantService extends IService<Merchant> { public interface IMerchantService extends IService<Merchant> {
Merchant info(String merchantId) ; Merchant info(String merchantId) ;
BigDecimal getPrice(String coin);
} }
...@@ -10,6 +10,8 @@ import com.fzm.mall.server.front.redis.MerchantRedis; ...@@ -10,6 +10,8 @@ import com.fzm.mall.server.front.redis.MerchantRedis;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -20,9 +22,13 @@ import org.springframework.stereotype.Service; ...@@ -20,9 +22,13 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IMerchantService { public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IMerchantService {
@Autowired @Autowired
private MerchantRedis merchantRedis; private MerchantRedis merchantRedis;
@Autowired
private MerchantMapper merchantMapper;
@Override @Override
public Merchant info(String merchantId) { public Merchant info(String merchantId) {
/*Merchant merchant = merchantRedis.getMerchant(merchantId); /*Merchant merchant = merchantRedis.getMerchant(merchantId);
...@@ -38,4 +44,8 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i ...@@ -38,4 +44,8 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
return getOne(queryWrapper); return getOne(queryWrapper);
} }
@Override
public BigDecimal getPrice(String coin) {
return merchantMapper.getPrice(coin);
}
} }
...@@ -34,8 +34,11 @@ import io.netty.util.internal.StringUtil; ...@@ -34,8 +34,11 @@ import io.netty.util.internal.StringUtil;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.annotations.Ignore;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -93,7 +96,6 @@ public class OrderController { ...@@ -93,7 +96,6 @@ public class OrderController {
String pid = ""; String pid = "";
try { try {
pid = orderService.createOrder(header.getUid(), orderVo, header.getType()); pid = orderService.createOrder(header.getUid(), orderVo, header.getType());
msgProducer.sendTTL(pid, QueueTTLTypeEnum.ORDER_CLOSE_TTL, configService.getConfig().getOrderCloseLimit());
} catch (Exception e) { } catch (Exception e) {
String msg = e.getMessage(); String msg = e.getMessage();
if (("商品不存在或下架").equals(msg)) { if (("商品不存在或下架").equals(msg)) {
...@@ -118,6 +120,46 @@ public class OrderController { ...@@ -118,6 +120,46 @@ public class OrderController {
return new ResponseVO<>(MallResponseEnum.SUCCESS, pid); return new ResponseVO<>(MallResponseEnum.SUCCESS, pid);
} }
@ApiOperation(value = "盲盒下单")
@PostMapping("/blindBox/createOrder")
public ResponseVO<String> blindBoxCreateOrder(@Ignore @RequestAttribute Header header, @RequestBody @Valid OrderBlindBoxVo orderVo) {
/**
* 參數校驗
*/
if(ObjectUtils.isEmpty(orderVo.getDelivery()) || StringUtils.isEmpty(orderVo.getGoodsId())){
return new ResponseVO<>(MallResponseEnum.PARAMETER_ERR);
}
String pid = "";
try {
pid = orderService.blindBoxCreateOrder(header.getUid(), header.getType(), orderVo);
} catch (Exception e) {
String msg = e.getMessage();
if (("商品不存在或下架").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.GOODS_NOT_BUY);
} else if (("库存不足!!!").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.GOOD_STOCK_NOT_ENOUGH);
} else if (("存在无效优惠券!!!").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.GOOD_COUPON_NOT_EXIST);
} else if (("一个商品只能使用一个优惠券!!!").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.GOOD_COUPON_NOT_EXIST);
} else if (("商品数量错误").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.GOOD_NUM_ERR);
} else if (("当前地区不支持快递").equals(msg)) {
return new ResponseVO<>(MallResponseEnum.NOT_SUPPORT_MAIL);
}else if("活动火爆".equals(msg)){
return new ResponseVO<>(MallResponseEnum.HOT_ACTIVITY);
} else{
e.printStackTrace();
//数据库异常
return new ResponseVO<>(MallResponseEnum.DB_ERROR);
}
}
return new ResponseVO<>(MallResponseEnum.SUCCESS, pid);
}
@ApiOperation(value = "支付 参数 pid") @ApiOperation(value = "支付 参数 pid")
@PostMapping("/pay") @PostMapping("/pay")
public ResponseVO<String> pay(@Ignore @RequestAttribute Header header, @RequestBody PayVo payVo) { public ResponseVO<String> pay(@Ignore @RequestAttribute Header header, @RequestBody PayVo payVo) {
...@@ -311,11 +353,6 @@ public class OrderController { ...@@ -311,11 +353,6 @@ public class OrderController {
return new ResponseVO<>(MallResponseEnum.SUCCESS, complaint); return new ResponseVO<>(MallResponseEnum.SUCCESS, complaint);
} }
public static void main(String[] args) {
BigDecimal amount = new BigDecimal(1900);
System.err.println(amount.multiply(new BigDecimal(1000)).setScale(2,BigDecimal.ROUND_DOWN));
}
@ApiOperation(value = "是否设置过支付密码") @ApiOperation(value = "是否设置过支付密码")
@PostMapping("/isSetPayPassword") @PostMapping("/isSetPayPassword")
public ResponseVO<Boolean> pay(@Ignore @RequestAttribute Header header) { public ResponseVO<Boolean> pay(@Ignore @RequestAttribute Header header) {
......
...@@ -26,6 +26,11 @@ import lombok.EqualsAndHashCode; ...@@ -26,6 +26,11 @@ import lombok.EqualsAndHashCode;
@ApiModel(value="Pay对象", description="支付订单结果表") @ApiModel(value="Pay对象", description="支付订单结果表")
public class Pay implements Serializable { public class Pay implements Serializable {
/**
* 支付状态:6->待付款
*/
public static final Integer PAY_STATE_TO_PAY = 6;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键自增编号") @ApiModelProperty(value = "主键自增编号")
...@@ -50,7 +55,7 @@ public class Pay implements Serializable { ...@@ -50,7 +55,7 @@ public class Pay implements Serializable {
@ApiModelProperty(value = "待支付金额") @ApiModelProperty(value = "待支付金额")
private BigDecimal unpaidAmount; private BigDecimal unpaidAmount;
@ApiModelProperty(value = "支付方式, 1->支付宝,2->微信 , 3->ccny") @ApiModelProperty(value = "支付方式, 1->支付宝,2->微信 , 3->ccny 4:积分")
private Integer payType; private Integer payType;
@ApiModelProperty(value = "订单号") @ApiModelProperty(value = "订单号")
...@@ -73,5 +78,11 @@ public class Pay implements Serializable { ...@@ -73,5 +78,11 @@ public class Pay implements Serializable {
private String outBizNo; private String outBizNo;
@ApiModelProperty(value = "用于抵扣的积分名称")
@TableField(exist = false)
private String coin;
@ApiModelProperty(value = "用于抵扣的积分数量")
@TableField(exist = false)
private BigDecimal integralDeduction;
} }
package com.fzm.mall.server.front.order.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class OrderBlindBoxVo {
private static final long serialVersionUID = 1L;
/**
* 是否直接提货,1->是
*/
public static final Integer DELIVERY_IMMEDIATELY = 1;
@ApiModelProperty(value = "是否直接提货,0->否,1->是", required = true)
private Integer delivery;
@ApiModelProperty(value = "收货人名称")
private String uname;
@ApiModelProperty(value = "收人手机号")
private String phone;
@ApiModelProperty(value = "提货地址")
private String address;
@ApiModelProperty(value = "省份名字或直辖市")
private String province;
@ApiModelProperty(value = "盲盒商品id", required = true)
private String goodsId;
@ApiModelProperty(value = "用于抵扣的积分的名称")
private String coin;
@ApiModelProperty(value = "用于抵扣的积分的数量")
private BigDecimal coinNumber;
@ApiModelProperty(value = "备注")
private String vNote;
@ApiModelProperty(value = "优惠券列表")
private List<String> goodsIdCouponIdList;
}
package com.fzm.mall.server.front.order.service;
import com.fzm.mall.server.front.goods.model.vo.SkuVo;
/**
* <p>
* 盲盒
* </p>
*
* @author wulixian
* @since 2022-02-23
*/
public interface IOrderBindBoxService {
/**
* 随机抽取盲盒sku
* @param goodsId
* @return
*/
SkuVo genRandomSku(String goodsId);
}
...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.fzm.mall.server.front.order.model.OrderDetail; import com.fzm.mall.server.front.order.model.OrderDetail;
import com.fzm.mall.server.front.order.model.po.NftOrderPo; import com.fzm.mall.server.front.order.model.po.NftOrderPo;
import com.fzm.mall.server.front.order.model.po.PreSaleOrderVo; import com.fzm.mall.server.front.order.model.po.PreSaleOrderVo;
import com.fzm.mall.server.front.order.model.vo.OrderBlindBoxVo;
import com.fzm.mall.server.front.order.model.vo.OrderVo; import com.fzm.mall.server.front.order.model.vo.OrderVo;
import com.fzm.mall.server.front.order.model.vo.ReturnMoneyDetail; import com.fzm.mall.server.front.order.model.vo.ReturnMoneyDetail;
...@@ -54,4 +55,13 @@ public interface IOrderService extends IService<Order> { ...@@ -54,4 +55,13 @@ public interface IOrderService extends IService<Order> {
String createPreSaleOrder(String uid, PreSaleOrderVo preSaleOrderVo); String createPreSaleOrder(String uid, PreSaleOrderVo preSaleOrderVo);
String createNftOrder(String uid, List<NftOrderPo> nftOrderPos); String createNftOrder(String uid, List<NftOrderPo> nftOrderPos);
/**
* 盲盒下单
* @param uid
* @param type
* @param orderVo
* @return
*/
String blindBoxCreateOrder(String uid, Integer type, OrderBlindBoxVo orderVo);
} }
package com.fzm.mall.server.front.order.service.impl;
import com.fzm.mall.server.front.constant.GoodMainConst;
import com.fzm.mall.server.front.goods.mapper.GoodSkuMapper;
import com.fzm.mall.server.front.goods.model.vo.SkuVo;
import com.fzm.mall.server.front.order.service.IOrderBindBoxService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author wulixian
* @since 2022/2/23
*/
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class IOrderBindBoxServiceImpl implements IOrderBindBoxService {
private final GoodSkuMapper goodSkuMapper;
@Override
public SkuVo genRandomSku(String goodsId) {
SkuVo result = null;
/**
* 从数据库获取库存大于0的盲盒sku列表
*/
List<SkuVo> skuList = goodSkuMapper.listAvailableSku(goodsId);
int difficulty = skuList.stream().map(SkuVo::getDifficulty).findFirst().get();
while(!CollectionUtils.isEmpty(skuList)){
result = genRandomSku(skuList, difficulty);
if (result == null) {
throw new RuntimeException("库存不足!!!");
}
//加时间锁
int i = goodSkuMapper.delStock(result.getSkuId(), GoodMainConst.BLIND_BOX_ORDER_SKU_NUM);
if (i != 1) {
/**
* 锁定库存失效,重置结果
*/
skuList.remove(result);
result = null;
}else{
break;
}
}
if (result == null) {
throw new RuntimeException("库存不足!!!");
}
return result;
}
/**
* @param prodList 从数据库获取的库存大于0的盲盒产品列表
* @param difficulty 正整数[1,10]
* @return 随机产品规格
* @descprition 随机获得产品
* @author lyz
* @create 2022/2/14 9:42
*/
public static SkuVo genRandomSku(List<SkuVo> prodList, int difficulty) {
int hiddenWeight = difficulty == 10 ? 1 : (10 - difficulty);
List<SkuVo> baseList = new ArrayList<>();
for (SkuVo prodItem : prodList) {
if (prodItem.getIsHide()) {
for (int i = 0; i < hiddenWeight; i++) {
baseList.add(prodItem);
}
} else {
for (int i = 0; i < difficulty; i++) {
baseList.add(prodItem);
}
}
}
//为了增加随机度,可以打开
//Collections.shuffle(baseList);
int base = baseList.size();
int randomNum = ThreadLocalRandom.current().nextInt(base);
return baseList.get(randomNum);
}
}
...@@ -11,6 +11,7 @@ import com.fzm.mall.server.front.goods.model.MarketingCouponSku; ...@@ -11,6 +11,7 @@ import com.fzm.mall.server.front.goods.model.MarketingCouponSku;
import com.fzm.mall.server.front.goods.model.vo.CouponVo; import com.fzm.mall.server.front.goods.model.vo.CouponVo;
import com.fzm.mall.server.front.goods.model.vo.SkuVo; import com.fzm.mall.server.front.goods.model.vo.SkuVo;
import com.fzm.mall.server.front.goods.service.IDistributionTemplateService; import com.fzm.mall.server.front.goods.service.IDistributionTemplateService;
import com.fzm.mall.server.front.goods.service.IGoodSkuPropService;
import com.fzm.mall.server.front.goods.service.IGoodSkuService; import com.fzm.mall.server.front.goods.service.IGoodSkuService;
import com.fzm.mall.server.front.goods.service.IMarketingCouponService; import com.fzm.mall.server.front.goods.service.IMarketingCouponService;
import com.fzm.mall.server.front.order.mapper.OrderMapper; import com.fzm.mall.server.front.order.mapper.OrderMapper;
...@@ -20,6 +21,7 @@ import com.fzm.mall.server.front.order.model.po.PayRestVO; ...@@ -20,6 +21,7 @@ import com.fzm.mall.server.front.order.model.po.PayRestVO;
import com.fzm.mall.server.front.order.model.vo.OrderSkuVo; import com.fzm.mall.server.front.order.model.vo.OrderSkuVo;
import com.fzm.mall.server.front.order.service.*; import com.fzm.mall.server.front.order.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fzm.mall.server.front.redis.GoodRedis;
import com.fzm.mall.server.front.redis.OrderRedis; import com.fzm.mall.server.front.redis.OrderRedis;
import com.fzm.mall.server.front.user.service.ICouponService; import com.fzm.mall.server.front.user.service.ICouponService;
import io.netty.util.internal.StringUtil; import io.netty.util.internal.StringUtil;
...@@ -73,6 +75,9 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS ...@@ -73,6 +75,9 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
@Autowired @Autowired
private IGoodsCouponService goodsCouponService; private IGoodsCouponService goodsCouponService;
@Autowired
private IGoodSkuPropService goodSkuPropService;
//平台-商户号 //平台-商户号
public static final String PLATFORM_MERCHANT_ID = "e3ac4b4a4e65460dbd9f1ec6cbd7a900"; public static final String PLATFORM_MERCHANT_ID = "e3ac4b4a4e65460dbd9f1ec6cbd7a900";
...@@ -99,6 +104,7 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS ...@@ -99,6 +104,7 @@ public class PayServiceImpl extends ServiceImpl<PayMapper, Pay> implements IPayS
for (Object oid : array) { for (Object oid : array) {
Order order = orderMapper.getByOid(oid.toString()); Order order = orderMapper.getByOid(oid.toString());
orderMapper.paySuccess(oid.toString(), System.currentTimeMillis()); orderMapper.paySuccess(oid.toString(), System.currentTimeMillis());
goodSkuPropService.delSkuProCachByOid(order.getOid());
orderRedis.delOrder(oid.toString()); orderRedis.delOrder(oid.toString());
/*//支付记录 /*//支付记录
PayRecord payRecord = new PayRecord(); PayRecord payRecord = new PayRecord();
......
...@@ -19,6 +19,6 @@ import java.util.List; ...@@ -19,6 +19,6 @@ import java.util.List;
*/ */
public interface FootMapper extends BaseMapper<Foot> { public interface FootMapper extends BaseMapper<Foot> {
@Select("select b.merchant_id,b.goods_id,b.type,b.name,b.thumb,b.default_price,a.update_time from user_foot a left join goods_spu b on a.goods_id = b.goods_id where a.uid = #{uid} and a.is_delete = 0 order by a.update_time desc limit #{start},#{size}") @Select("select b.merchant_id,b.goods_id,b.type,b.name,b.thumb,b.default_price,a.update_time,b.sales_type from user_foot a left join goods_spu b on a.goods_id = b.goods_id where a.uid = #{uid} and a.is_delete = 0 order by a.update_time desc limit #{start},#{size}")
List<FootGoodsVo> getGoods(@Param("uid") String uid, @Param("start") int start, @Param("size") Integer size); List<FootGoodsVo> getGoods(@Param("uid") String uid, @Param("start") int start, @Param("size") Integer size);
} }
...@@ -26,4 +26,7 @@ public class FootGoodsVo { ...@@ -26,4 +26,7 @@ public class FootGoodsVo {
private Integer type; private Integer type;
private Long updateTime; private Long updateTime;
@ApiModelProperty(value = "(销售方式)1.普通 4.盲盒")
private Integer salesType;
} }
...@@ -54,14 +54,14 @@ chain: ...@@ -54,14 +54,14 @@ chain:
#乐映测试平行链: #乐映测试平行链:
para: para:
rpc-url: http://172.22.20.100:8901 rpc-url: http://139.9.231.117:12021
withhold: 1Ae6FfgdYJn6LLaqDoRjwga3j4TTmMq3t7 withhold: 1417K9fd5vt4zYW86xinWiCbAkNP794aNy
withhold-key: a4c49dcb35e0032dc8db5891dc81481943b68fc558ce93ce74d0382c1d104934 withhold-key: 19d78691584930407e63cd35ac6e67fae6113894b41812e65847d4a365a802a0
token-manager: 1N2ABERwHgxGhebVw6fVSwaQ5uLAysmGEu token-manager: 1KEBcdmMPfUV2suAqgkyDpdm4brZbYmdfF
token-manager-key: 4e92bda2477ded0e7c07a9e3acd2370de8d7401c68cc83ee8376806db3121e77 token-manager-key: 5d872407fb2769854dcca6203d70696feced7099c588a6d9146a122025585e41
title: user.p.nftChain. title: user.p.mall.
cName: user.evm.0x72b80fbf7312e4ddefbfb235754f11915d10b88cefd0e0e96b4d7f66b99cce05 cName: user.evm.0xb3ae98ac253679602d54d1513aa9cad7d1b10d5f5117d5ce999c1bf67906ba99
cAddr: 1BzfFBFf99DRhqfunEXhPsZRDgPwUWjab6 cAddr: 15DtbSyS4eVFxdF87jmrcAdXMSAwXEHVLW
type: para type: para
mybatis-plus: mybatis-plus:
......
...@@ -7,4 +7,15 @@ ...@@ -7,4 +7,15 @@
from goods_sku from goods_sku
where goods_id = #{goodsId} where goods_id = #{goodsId}
</select> </select>
<select id="listAvailableSku" resultType="com.fzm.mall.server.front.goods.model.vo.SkuVo">
select sk.*, sp.difficulty, sp.merchant_id, sp.blind_box_price as blindBoxprice, sp.name
from goods_sku sk
left join goods_spu sp on sk.goods_id = sp.goods_id
where sk.goods_id = #{goodsId} and sk.status = '1' and sk.stock > 0
</select>
<update id="delStock">
update goods_sku set stock =stock - #{num} where sku_id = #{skuId} and stock >= #{num}
</update>
</mapper> </mapper>
...@@ -2,4 +2,9 @@ ...@@ -2,4 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fzm.mall.server.front.merchant.mapper.MerchantMapper"> <mapper namespace="com.fzm.mall.server.front.merchant.mapper.MerchantMapper">
<select id="getPrice" resultType="decimal">
select price
from merchant_integral
where label = #{coin}
</select>
</mapper> </mapper>
...@@ -58,4 +58,5 @@ NOT_SUPPORT_BUY_MYSELF=\u6682\u4E0D\u652F\u6301\u81EA\u5DF1\u4E70\u81EA\u5DF1\u7 ...@@ -58,4 +58,5 @@ NOT_SUPPORT_BUY_MYSELF=\u6682\u4E0D\u652F\u6301\u81EA\u5DF1\u4E70\u81EA\u5DF1\u7
ONLY_SUPPORT_MAIL=\u5F53\u524D\u5546\u54C1\u4EC5\u652F\u6301\u63D0\u8D27 ONLY_SUPPORT_MAIL=\u5F53\u524D\u5546\u54C1\u4EC5\u652F\u6301\u63D0\u8D27
RECORD_EXIST=\u76F8\u5173\u4EA4\u6613\u8BB0\u5F55\u5DF2\u5B58\u5728\uFF0C\u53D6\u6D88\u5931\u8D25 RECORD_EXIST=\u76F8\u5173\u4EA4\u6613\u8BB0\u5F55\u5DF2\u5B58\u5728\uFF0C\u53D6\u6D88\u5931\u8D25
ADDR_INVALID=\u65E0\u6548\u5730\u5740 ADDR_INVALID=\u65E0\u6548\u5730\u5740
SEND_CODE_ERR=\u77ED\u4FE1\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5 SEND_CODE_ERR=\u77ED\u4FE1\u53D1\u9001\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5
\ No newline at end of file HOT_ACTIVITY=\u6D3B\u52A8\u592A\u8FC7\u706B\u7206\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5
\ No newline at end of file
package com.fzm.mall.server.front;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author lyz
* @mail lyz@disanbo.com
* @create 2022/2/10 14:20
* @description
*/
public class BlindBoxTest {
public static void main(String[] args) {
ProdItem prod1 = ProdItem.builder().prodId("111111").isHidden(false).build();
ProdItem prod2 = ProdItem.builder().prodId("222222").isHidden(false).build();
ProdItem prod3 = ProdItem.builder().prodId("333333").isHidden(false).build();
ProdItem prod4 = ProdItem.builder().prodId("444444").isHidden(false).build();
ProdItem prod5 = ProdItem.builder().prodId("555555").isHidden(true).build();
ProdItem prod6 = ProdItem.builder().prodId("666666").isHidden(false).build();
List<ProdItem> prodList = new ArrayList<>();
prodList.add(prod1);
prodList.add(prod6);
prodList.add(prod3);
prodList.add(prod2);
prodList.add(prod5);
prodList.add(prod4);
System.out.println(genRandomProd(prodList, 1));
}
/**
* @descprition 随机获得产品
* @author lyz
* @create 2022/2/14 9:42
* @param prodList 从数据库获取的库存大于0的盲盒产品列表
* @param difficulty 正整数[1,10]
* @return 随机产品编号
*/
public static String genRandomProd(List<ProdItem> prodList, int difficulty){
int hiddenWeight = difficulty == 10 ? 1 : (10 - difficulty);
List<String> baseList = new ArrayList<>();
for(ProdItem prodItem : prodList){
if(prodItem.isHidden){
for(int i=0;i<hiddenWeight;i++){
baseList.add(prodItem.prodId);
}
}else{
for(int i=0;i<difficulty;i++){
baseList.add(prodItem.prodId);
}
}
}
//为了增加随机度,可以打开
//Collections.shuffle(baseList);
int base = baseList.size();
int randomNum = ThreadLocalRandom.current().nextInt(base);
return baseList.get(randomNum);
}
@Data
@Builder
static class ProdItem {
private String prodId;
private boolean isHidden;
}
}
...@@ -2524,6 +2524,9 @@ ALTER TABLE `order_detail` ...@@ -2524,6 +2524,9 @@ ALTER TABLE `order_detail`
update user_asset set goods_coin = coin; update user_asset set goods_coin = coin;
ALTER TABLE `user_asset_record` ADD COLUMN `goods_coin` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商品coin'; ALTER TABLE `user_asset_record` ADD COLUMN `goods_coin` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '商品coin';
ALTER TABLE `merchant_integral`
ADD COLUMN `price` decimal(20,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '行情 1积分=n人民币';
--2022-2-22 --2022-2-22
ALTER TABLE `goods_spu` ALTER TABLE `goods_spu`
ADD COLUMN `sales_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '(销售方式)1.普通 2.盲盒'; ADD COLUMN `sales_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '(销售方式)1.普通 2.盲盒';
...@@ -2549,3 +2552,4 @@ ALTER TABLE `goods_spu` ...@@ -2549,3 +2552,4 @@ ALTER TABLE `goods_spu`
ALTER TABLE `goods_spu` ALTER TABLE `goods_spu`
ADD COLUMN `preheat_end_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '预热结束时间'; ADD COLUMN `preheat_end_time` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '预热结束时间';
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