Browse Source

修正添加到购物车

master
xyiege 3 years ago
parent
commit
9bde254f13
  1. 13
      src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java
  2. 32
      src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java
  3. 3
      src/main/resources/mapper/szwh/OrderMapper.xml
  4. 11
      src/main/resources/mapper/szwh/UserMapper.xml

13
src/main/java/cn/chjyj/szwh/controller/api/GoodsController.java

@ -1,13 +1,8 @@
package cn.chjyj.szwh.controller.api;
import cn.chjyj.szwh.annotation.PassToken;
import cn.chjyj.szwh.bean.Goods;
import cn.chjyj.szwh.controller.BaseController;
import cn.chjyj.szwh.service.GoodsService;
import cn.chjyj.szwh.utils.AjaxResult;
import cn.chjyj.szwh.utils.SzwhApiUtils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@ -39,9 +34,9 @@ public class GoodsController extends BaseController {
@RequestMapping(value = "/addShoppingCar")
public JSONObject addShoppingCar(HttpServletRequest request){
long start=System.currentTimeMillis();
String userIsli = request.getParameter("user_isli");
String goodsIsli = request.getParameter("goods_isli");
String userYears= request.getParameter("user_years");
String userIsli = request.getParameter("user_isli").trim();
String goodsIsli = request.getParameter("goods_isli").trim();
String userYears= request.getParameter("use_years").trim();
Integer uyears = StringUtils.isEmpty(userYears)?1:Integer.valueOf(userYears);
// do add
Map<String,Object> retmap =goodsService.addShopCar(userIsli,goodsIsli,uyears);
@ -50,7 +45,7 @@ public class GoodsController extends BaseController {
// get msg
jsonObject.put("code",retmap.get("code"));
jsonObject.put("msg",retmap.get("msg"));
jsonObject.put("data",retmap);
// jsonObject.put("data",retmap);
jsonObject.put("useTime",howUse);
return jsonObject;
}

32
src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java

@ -622,21 +622,25 @@ public class GoodsServiceImpl implements GoodsService {
if(goods==null){
retmap.put("code",400);
retmap.put("msg","没有该标的");
}
if(goods.getGoodsStatus()!=1){
retmap.put("code",400);
retmap.put("msg","该标的现不在上架中");
}
if(goods.getContractStatus()!=1){
retmap.put("code",400);
retmap.put("msg","标的未申请合约关联,不可购买");
}
if(goods.getUserIslicode() == userIsli){
retmap.put("code",400);
retmap.put("msg","您是标的的授权方,不可添加");
}else {
if (goods.getGoodsStatus() != 1) {
retmap.put("code", 400);
retmap.put("msg", "该标的现不在上架中");
}
if (goods.getContractStatus() != 1) {
retmap.put("code", 400);
retmap.put("msg", "标的未申请合约关联,不可购买");
}
if (goods.getUserIslicode() == userIsli) {
retmap.put("code", 400);
retmap.put("msg", "您是标的的授权方,不可添加");
}
}
//
Map ordmap = new HashMap();
ordmap.put("o.buy_islicode",userIsli);
ordmap.put("od.goods_islicode",goodsIsli);
ordmap.put("od.is_deleted",0);
ordmap.put("ostatus_not",5);
OrderDetailVo orderDetailVo= orderMapper.getOrderDetailVOByMap(ordmap);
if(orderDetailVo!=null){
@ -673,9 +677,9 @@ public class GoodsServiceImpl implements GoodsService {
}else{
carjson.put("goods_islicode",goodsIsli);
carjson.put("use_years",userYears);
RedisUtil.set(shopRedisKey,carjson);
RedisUtil.set(shopRedisKey,carjson.toJSONString());
}
return null;
return retmap;
}
/**

3
src/main/resources/mapper/szwh/OrderMapper.xml

@ -118,9 +118,8 @@
${k} = #{v}
</if>
<if test="k=='ostatus_not'">
o.status <![CDATA[ <> ]]> #{v};
o.status <![CDATA[ <> ]]> #{v}
</if>
</foreach>
</if>
</where>

11
src/main/resources/mapper/szwh/UserMapper.xml

@ -22,18 +22,9 @@
)SELECT * FROM mu ORDER BY id DESC;
</select>
<!--根据uid查询用户-->
<!-- <select id="getUserByUid" parameterType="java.lang.Integer" resultType="cn.chjyj.szwh.bean.User">-->
<!-- select-->
<!-- <include refid="column"/>-->
<!-- from-->
<!-- <include refid="tbName"/>-->
<!-- where uid=#{uid}-->
<!-- </select>-->
<!--查询用户名,加上密码-->
<select id="getUserByIsli" parameterType="java.lang.String" resultType="cn.chjyj.szwh.bean.User">
select<include refid="column"/>,password
select<include refid="column"/>
from
<include refid="tbName"/>
where user_isli=#{userIsli} limit 1;

Loading…
Cancel
Save