|
@@ -8,21 +8,25 @@
|
|
|
|
|
|
package com.zskk.shop.service;
|
|
package com.zskk.shop.service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
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.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.zskk.shop.controller.bean.GoodAdBean;
|
|
import com.zskk.shop.controller.bean.GoodAdBean;
|
|
import com.zskk.shop.controller.bean.GoodBean;
|
|
import com.zskk.shop.controller.bean.GoodBean;
|
|
import com.zskk.shop.controller.bean.GoodDescribeBean;
|
|
import com.zskk.shop.controller.bean.GoodDescribeBean;
|
|
import com.zskk.shop.controller.bean.GoodPriceBean;
|
|
import com.zskk.shop.controller.bean.GoodPriceBean;
|
|
|
|
+import com.zskk.shop.controller.bean.UserBean;
|
|
import com.zskk.shop.dao.GoodMapper;
|
|
import com.zskk.shop.dao.GoodMapper;
|
|
import com.zskk.shop.dao.entry.GoodAd;
|
|
import com.zskk.shop.dao.entry.GoodAd;
|
|
import com.zskk.shop.dao.entry.GoodBase;
|
|
import com.zskk.shop.dao.entry.GoodBase;
|
|
import com.zskk.shop.dao.entry.GoodDescribe;
|
|
import com.zskk.shop.dao.entry.GoodDescribe;
|
|
import com.zskk.shop.dao.entry.GoodPrice;
|
|
import com.zskk.shop.dao.entry.GoodPrice;
|
|
|
|
+import com.zskk.shop.utils.ToolsUtil;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class GoodService {
|
|
public class GoodService {
|
|
@@ -70,13 +74,49 @@ public class GoodService {
|
|
return goodMapper.queryGoodBaseCount(status, search);
|
|
return goodMapper.queryGoodBaseCount(status, search);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 编辑或添加商品基本信息
|
|
|
|
+ * @param base
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Transactional
|
|
|
|
+ public Integer saveGoodBase(UserBean user, GoodBase base, BigDecimal price, BigDecimal discountPrice){
|
|
|
|
+ base.setStatus(GOOD_OFFLINE);
|
|
|
|
+ base.setSort(0);
|
|
|
|
+ base.setUid(user.getUserid());
|
|
|
|
+ base.setCtime(ToolsUtil.getNow());
|
|
|
|
+ if (base.getGid().equals(0)){
|
|
|
|
+ goodMapper.addGoodBase(base);
|
|
|
|
+
|
|
|
|
+ GoodPrice priceObj = new GoodPrice();
|
|
|
|
+ priceObj.setCtime(base.getCtime());
|
|
|
|
+ priceObj.setDiscountPrice(discountPrice);
|
|
|
|
+ priceObj.setEtime(0);
|
|
|
|
+ priceObj.setGid(base.getGid());
|
|
|
|
+ priceObj.setPrice(price);
|
|
|
|
+ priceObj.setStatus(1);
|
|
|
|
+ priceObj.setStime(0);
|
|
|
|
+ priceObj.setUid(user.getUserid());
|
|
|
|
+ priceObj.setUseType(0);
|
|
|
|
+ goodMapper.addGoodPrice(priceObj);
|
|
|
|
+ }else{
|
|
|
|
+ goodMapper.updateGoodBase(base);
|
|
|
|
+ GoodPrice priceObj = goodMapper.queryGoodPrices(base.getGid());
|
|
|
|
+ priceObj.setPrice(price);
|
|
|
|
+ priceObj.setDiscountPrice(discountPrice);
|
|
|
|
+ goodMapper.updateGoodPrice(priceObj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return base.getGid();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询商品价格 1.0版本没有支持时间和类型
|
|
* 查询商品价格 1.0版本没有支持时间和类型
|
|
* @param gid
|
|
* @param gid
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public GoodPrice queryGoodPrice(Integer gid){
|
|
public GoodPrice queryGoodPrice(Integer gid){
|
|
- return goodMapper.queryGoodPrices(gid).get(0);
|
|
|
|
|
|
+ return goodMapper.queryGoodPrices(gid);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -115,6 +155,7 @@ public class GoodService {
|
|
bean.setPackageid(base.getPackageid());
|
|
bean.setPackageid(base.getPackageid());
|
|
bean.setPackageName(bean.getPackageName());
|
|
bean.setPackageName(bean.getPackageName());
|
|
bean.setCtime(base.getCtime());
|
|
bean.setCtime(base.getCtime());
|
|
|
|
+ bean.setStatus(base.getStatus());
|
|
return bean;
|
|
return bean;
|
|
}
|
|
}
|
|
|
|
|