添加商品描述和价格冗余字段

This commit is contained in:
xiaofeng 2019-07-16 01:08:26 +08:00
parent c1e34b908c
commit 2dc243a18f
9 changed files with 91 additions and 14 deletions

View File

@ -98,7 +98,7 @@
</div> </div>
<van-goods-action> <van-goods-action>
<van-goods-action-mini-btn icon="like-o" @click="onFavoriteClicked"> <van-goods-action-mini-btn icon="like-o" :class="{active:hasCollectionType === 1 }" @click="onFavoriteClicked">
收藏 收藏
</van-goods-action-mini-btn> </van-goods-action-mini-btn>
<van-goods-action-mini-btn icon="cart" :info="cartCount > 0 ? cartCount : undefined" @click="onClickCart"> <van-goods-action-mini-btn icon="cart" :info="cartCount > 0 ? cartCount : undefined" @click="onClickCart">
@ -208,6 +208,7 @@
calSkuPriceResult: { calSkuPriceResult: {
}, },
hasCollectionType:0
}; };
}, },
@ -327,11 +328,14 @@
// alert("hasCollectionType==" + hasCollectionType); // alert("hasCollectionType==" + hasCollectionType);
collectionSpu(id,hasCollectionType).then(data =>{ collectionSpu(id,hasCollectionType).then(data =>{
let v = data; let v = data;
if (hasCollectionType == 1 && v){ this.hasCollectionType = hasCollectionType;
alert("商品已收藏"); // if (hasCollectionType == 1 && v){
}else if (hasCollectionType == 2 && v){ // // alert("");
alert("商品已取消"); // this.hasCollectionType = hasCollectionType;
} // }else if (hasCollectionType == 2 && v){
// // alert("");
// this.hasCollectionType = hasCollectionType;
// }
}) })
}); });
@ -448,6 +452,9 @@
<style lang="less"> <style lang="less">
.goods { .goods {
.active {
color: #e50f3d;
}
padding-bottom: 50px; padding-bottom: 50px;
&-swipe { &-swipe {

View File

@ -7,19 +7,27 @@
@load="onLoad" @load="onLoad"
> >
<div v-for="(item,index) in list" :key="index"> <div v-for="(item,index) in list" :key="index">
<van-swipe-cell :right-width="65" :on-close="onClose(item)"> <!-- <van-swipe-cell :right-width="65" :on-close="onClose(item)">-->
<product-card :product='item' /> <!-- <product-card :product='item' />-->
<span>{{item.spuName}}</span> <!-- <span>{{item.spuName}}</span>-->
<span slot="right" >删除</span> <!-- <span slot="right" >删除</span>-->
</van-swipe-cell> <!-- </van-swipe-cell>-->
<van-card
:price="formatPrice(item.price)"
:desc="item.sellPoint"
:title="item.spuName"
:thumb="item.spuImage"
/>
</div> </div>
</van-list> </van-list>
</div> </div>
</template> </template>
<script> <script>
// import { Card } from 'vant';
import { GetFavoritePage ,DelFavorite} from "../../../api/user.js"; import { GetFavoritePage ,DelFavorite} from "../../../api/user.js";
// Vue.use(Card);
export default { export default {
data(){ data(){
return{ return{
@ -31,6 +39,9 @@ export default {
} }
}, },
methods:{ methods:{
formatPrice(data) {
return (data / 100).toFixed(2);
},
onClose(item){ onClose(item){
return function(clickPosition, instance) { return function(clickPosition, instance) {
switch (clickPosition) { switch (clickPosition) {

View File

@ -37,6 +37,16 @@ public class ProductSpuCollectionMessage {
*/ */
private String spuImage; private String spuImage;
/**
* 卖点
*/
private String sellPoint;
/**
* 价格单位
*/
private Integer price;
/** /**
* 1 收藏 2 取消 * 1 收藏 2 取消
*/ */

View File

@ -6,11 +6,14 @@ import cn.iocoder.mall.product.api.constant.ProductErrorCodeEnum;
import cn.iocoder.mall.product.api.message.ProductSpuCollectionMessage; import cn.iocoder.mall.product.api.message.ProductSpuCollectionMessage;
import cn.iocoder.mall.product.dao.ProductSpuMapper; import cn.iocoder.mall.product.dao.ProductSpuMapper;
import cn.iocoder.mall.product.dataobject.ProductSpuDO; import cn.iocoder.mall.product.dataobject.ProductSpuDO;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.apache.rocketmq.spring.core.RocketMQTemplate;
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 javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
/** /**
* ProductSpuCollectionServiceImpl * ProductSpuCollectionServiceImpl
@ -47,9 +50,14 @@ public class ProductSpuCollectionServiceImpl implements ProductSpuCollectionServ
*/ */
private void sendProductSpuCollectionMessage(final ProductSpuDO productSpuDO, final Integer hasCollectionType, private void sendProductSpuCollectionMessage(final ProductSpuDO productSpuDO, final Integer hasCollectionType,
final Integer userId) { final Integer userId) {
List<String> result = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().trimResults().split(productSpuDO.getPicUrls()));
ProductSpuCollectionMessage productSpuCollectionMessage = new ProductSpuCollectionMessage() ProductSpuCollectionMessage productSpuCollectionMessage = new ProductSpuCollectionMessage()
.setSpuId(productSpuDO.getId()).setSpuName(productSpuDO.getName()) .setSpuId(productSpuDO.getId())
.setSpuImage(productSpuDO.getPicUrls()).setHasCollectionType(hasCollectionType) .setSpuName(productSpuDO.getName())
.setSpuImage(result.size() > 0 ? result.get(0) : "")
.setSellPoint(productSpuDO.getSellPoint())
.setPrice(productSpuDO.getPrice())
.setHasCollectionType(hasCollectionType)
.setUserId(userId); .setUserId(userId);
rocketMQTemplate.convertAndSend(ProductSpuCollectionMessage.TOPIC, productSpuCollectionMessage); rocketMQTemplate.convertAndSend(ProductSpuCollectionMessage.TOPIC, productSpuCollectionMessage);
} }

View File

@ -45,6 +45,16 @@ public class UserProductSpuCollectionsBO implements Serializable {
*/ */
private String spuImage; private String spuImage;
/**
* 卖点
*/
private String sellPoint;
/**
* 价格单位
*/
private Integer price;
/** /**
* 创建时间 * 创建时间
*/ */

View File

@ -46,6 +46,16 @@ public class UserProductSpuCollectionsAddDTO implements Serializable {
*/ */
private String spuImage; private String spuImage;
/**
* 卖点
*/
private String sellPoint;
/**
* 价格单位
*/
private Integer price;
/** /**
* 创建时间 * 创建时间
*/ */

View File

@ -50,6 +50,16 @@ public class UserProductSpuCollectionsDO implements Serializable {
*/ */
private String spuImage; private String spuImage;
/**
* 卖点
*/
private String sellPoint;
/**
* 价格单位
*/
private Integer price;
/** /**
* 创建时间 * 创建时间
*/ */

View File

@ -11,6 +11,8 @@ import cn.iocoder.mall.user.api.dto.UserProductSpuCollectionsUpdateDTO;
import cn.iocoder.mall.user.biz.convert.UserProductSpuCollectionsConvert; import cn.iocoder.mall.user.biz.convert.UserProductSpuCollectionsConvert;
import cn.iocoder.mall.user.biz.dao.UserProductSpuCollectionsMapper; import cn.iocoder.mall.user.biz.dao.UserProductSpuCollectionsMapper;
import cn.iocoder.mall.user.biz.dataobject.UserProductSpuCollectionsDO; import cn.iocoder.mall.user.biz.dataobject.UserProductSpuCollectionsDO;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
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 org.springframework.util.CollectionUtils;
@ -33,6 +35,10 @@ public class UserProductSpuCollectionsServiceImpl implements UserProductSpuColle
@Autowired @Autowired
private UserProductSpuCollectionsMapper userProductSpuCollectionsMapper; private UserProductSpuCollectionsMapper userProductSpuCollectionsMapper;
// TODO 暂时先使用冗余字段有需要在对接实时数据查询
// @Reference(validation = "true", version = "${dubbo.consumer.PromotionActivityService.version}")
// private ProductSpuService productSpuService;
@Override @Override
public int addUserSkuCollections(UserProductSpuCollectionsAddDTO userProductSpuCollectionsAddDTO) { public int addUserSkuCollections(UserProductSpuCollectionsAddDTO userProductSpuCollectionsAddDTO) {
@ -72,6 +78,11 @@ public class UserProductSpuCollectionsServiceImpl implements UserProductSpuColle
return CommonResult.success( return CommonResult.success(
new UserProductSpuCollectionsPageBO().setList(Collections.emptyList()).setTotal(totalCount)); new UserProductSpuCollectionsPageBO().setList(Collections.emptyList()).setTotal(totalCount));
} }
for (UserProductSpuCollectionsDO userProductSpuCollectionsDO : list
) {
List<String> result = Lists.newArrayList(Splitter.on(",").omitEmptyStrings().trimResults().split(userProductSpuCollectionsDO.getSpuImage()));
userProductSpuCollectionsDO.setSpuImage(result.size() > 0 ? result.get(0) : "");
}
UserProductSpuCollectionsPageBO userProductSpuCollectionsPageBO = new UserProductSpuCollectionsPageBO(); UserProductSpuCollectionsPageBO userProductSpuCollectionsPageBO = new UserProductSpuCollectionsPageBO();
userProductSpuCollectionsPageBO.setList(UserProductSpuCollectionsConvert.INSTANCE.convert(list)); userProductSpuCollectionsPageBO.setList(UserProductSpuCollectionsConvert.INSTANCE.convert(list));

View File

@ -4,7 +4,7 @@
<sql id="FIELDS"> <sql id="FIELDS">
id, user_id, nickname, spu_id, spu_name, id, user_id, nickname, spu_id, spu_name,
spu_image, create_time, update_time, spu_image,sell_point,price, create_time, update_time,
deleted deleted
</sql> </sql>