package cn.changeHappy.exchange.controller;
import cn.changeHappy.exchange.pojo.SearchGoodsEntity;
import cn.changeHappy.exchange.servcie.ExchangeService;
import cn.changeHappy.exchange.utils.R;
import cn.changeHappy.exchange.utils.ValidatorUtils;
import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
import static cn.changeHappy.exchange.utils.R.success;
/**
* @ClassNameExchangeHomepageController
* @Description
* @Author
* @Date2021/10/10 17:45
* @Version V1.0
**/
@RestController
@RequestMapping("/exchangeHomePage")
public class ExchangeHomepageController {
@Autowired
ExchangeService exchangeService;
/**
* 查询所有商品分类
* @return
* @throws ParseException
*/
@GetMapping("/selectExchangeHomepage")
public R<List<Map<String,Object>>> selectChangeHappyBzdmAllType() throws Exception {
List<Map<String,Object>> exchangeList = exchangeService.selectChangeHappyBzdmAllType();
return success(exchangeList);
}
@Data
public static class SearchBzdmAllTypeEntity{
private String bzdm;
}
/**
* 查询主页活动图片
* @return
* @throws ParseException
*/
@GetMapping("/selectChangeHappyBzdmImg")
public List<Map<String,Object>> selectChangeHappyBzdmImg() throws Exception {
List<Map<String,Object>> exchangeList = exchangeService.selectChangeHappyBzdmImg();
return exchangeList;
}
@Data
public static class SelectChangeHappyBzdmImgEntity{
private String bzdm;
}
/**
* 根据商品类型查询符合类型商品
* @param searchHomePageByGoodsAllTypeEntity
* @return
* @throws ParseException
*/
//TODO: 2021/10/16 暂停使用
@PostMapping("/selectExchangeHomepageByGoodsType")
public List<Map<String,Object>> selectExchangeHomepageByGoodsType(@RequestBody SearchHomePageByGoodsAllTypeEntity searchHomePageByGoodsAllTypeEntity) throws Exception {
ValidatorUtils.validateEntity(searchHomePageByGoodsAllTypeEntity);
Map<String,Object> map = JSON.parseObject(JSON.toJSONString(searchHomePageByGoodsAllTypeEntity), Map.class);
List<Map<String,Object>> exchangeList = exchangeService.selectExchangeHomepageByGoodsType(map);
return exchangeList;
}
@Data
public static class SearchHomePageByGoodsAllTypeEntity{
private Integer goodsType;
}
/**
* 查询主页所有商品信息 按照置顶时间排序
* @param searchGoodsEntity
* @return
* @throws ParseException
*/
@PostMapping("/selectExchangeGoods")
public List<Map<String,Object>> selectExchangeGoods(@RequestBody SearchGoodsEntity searchGoodsEntity) throws Exception {
ValidatorUtils.validateEntity(searchGoodsEntity);
Map<String,Object> map = JSON.parseObject(JSON.toJSONString(searchGoodsEntity), Map.class);
List<Map<String,Object>> exchangeList = exchangeService.selectExchangeGoods(searchGoodsEntity);
return exchangeList;
}
/**
* 查询分类表 ,首页导航栏
* @return
* @throws ParseException
*/
@PostMapping("/selectExchangeIndex")
public List<Map<String,Object>> selectExchangeIndex() throws Exception {
List<Map<String,Object>> exchangeList = exchangeService.selectExchangeIndex();
return exchangeList;
}
/**
* 查询热门商品接口
* @return
* @throws ParseException
*/
@PostMapping("/selectExchangeIndexHotGoods")
public List<Map<String,Object>> selectExchangeIndexHotGoods() throws Exception {
List<Map<String,Object>> exchangeHotGoodsList = exchangeService.selectExchangeIndexHotGoods();
return exchangeHotGoodsList;
}
/**
* 查询收藏商品接口
* @return
*/
@PostMapping("/selectExchangeCollectGoods")
public Map<String,Object> selectExchangeCollectGoods(@RequestBody SearchCollectGoodsEntity searchCollectGoodsEntity) throws Exception {
ValidatorUtils.validateEntity(searchCollectGoodsEntity);
Map<String,Object> map = JSON.parseObject(JSON.toJSONString(searchCollectGoodsEntity), Map.class);
Map<String,Object> exchangeHotGoodsList = exchangeService.selectExchangeCollectGoods(map);
return exchangeHotGoodsList;
}
@Data
public static class SearchCollectGoodsEntity{
private String userId;
}
/**
* 新增收藏商品
*/
@PostMapping("/insertGoodsByUserId")
public Map<String,Object> insertCollectGoods(@RequestBody InsertCollectGoodsEntity insertUserGoodsEntity) throws Exception {
ValidatorUtils.validateEntity(insertUserGoodsEntity);
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(insertUserGoodsEntity), Map.class);
Map<String, Object> stringObjectMap = exchangeService.insertCollectGoods(map);
return stringObjectMap;
}
@Data
public static class InsertCollectGoodsEntity {
private String userId;
private String goodsId;
}
/**
* 取消收藏商品
*/
@PostMapping("/deleteGoodsByUserId")
public Map<String,Object> deleteGoodsByUserId(@RequestBody DeleteCollectGoodsEntity deleteCollectGoodsEntity) throws Exception {
ValidatorUtils.validateEntity(deleteCollectGoodsEntity);
Map<String, Object> map = JSON.parseObject(JSON.toJSONString(deleteCollectGoodsEntity), Map.class);
Map<String, Object> stringObjectMap = exchangeService.deleteGoodsByUserId(map);
return stringObjectMap;
}
@Data
public static class DeleteCollectGoodsEntity {
private String userId;
private String goodsId;
}
/**
* 查询通知页面
* @return
* @throws ParseException
*/
@PostMapping("/selectExchangeInform")
public Map<String,Object> selectExchangeInform(String headlineType) throws Exception {
Map<String,Object> exchangeInformMap = exchangeService.selectExchangeInform(headlineType);
return exchangeInformMap;
}
/**
* 首页图片
* @return
*/
@GetMapping("selectHomepageSlideshow")
public List<Map<String,Object>> selectHomepageSlideshow() throws Exception{
return exchangeService.selectHomepageSlideshow();
}
/**
* 查询限时购商品
* @return
*/
@PostMapping("queryTimeShopping")
public List<Map<String,Object>> queryTimeShopping() throws Exception{
return exchangeService.queryTimeShopping();
}
/**
* 查询新人专享
* @param searchGoodsEntity
* @return
* @throws ParseException
*/
@PostMapping("/queryPeopleVip")
public List<Map<String,Object>> queryPeopleVip(@RequestBody SearchGoodsEntity searchGoodsEntity) throws Exception {
ValidatorUtils.validateEntity(searchGoodsEntity);
Map<String,Object> map = JSON.parseObject(JSON.toJSONString(searchGoodsEntity), Map.class);
List<Map<String,Object>> exchangeList = exchangeService.queryPeopleVip(searchGoodsEntity);
return exchangeList;
}
}
package cn.changeHappy.exchange.mapper;
import cn.changeHappy.exchange.pojo.SearchGoodsEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* @description: 告警配置
* @author: Duansx
* @date: Created in 2019/8/23 10:21
*/
@Mapper
public interface ExchangeMapper {
List<Map<String, Object>> selectChangeHappyBzdmAllType();
List<Map<String, Object>> selectExchangeHomepageByGoodsType(Map<String, Object> map);
List<Map<String, Object>> selectExchangeIndex();
List<Map<String, Object>> selectExchangeIndexHotGoods();
int selectExchangeCollectGoodsCount(Map<String,Object> map);
List<Map<String, Object>> selectExchangeCollectGoodsList(Map<String, Object> map);
Map<String, Object> selectGoodsByGoodsId(String stringObjectMap);
int insertCollectGoods(Map<String, Object> map);
List<Map<String, Object>> selectExchangeInform(String headlineType);
List<Map<String, Object>> selectHomepageSlideshow();
List<Map<String, Object>> selectChangeHappyBzdmImg();
List<Map<String, Object>> selectFileByGoodsId(String id);
int deleteGoodsByUserId(Map<String, Object> map);
int selectUserAttention(Map<String, Object> map);
List<Map<String, Object>> selectExchangeGoods(SearchGoodsEntity searchGoodsEntity);
List<Map<String, Object>> queryTimeShopping();
List<Map<String, Object>> queryPeopleVip(SearchGoodsEntity searchGoodsEntity);
}
package cn.changeHappy.exchange.servcie.impl;
import cn.changeHappy.exchange.mapper.ExchangeMapper;
import cn.changeHappy.exchange.mapper.ExchangeOrderMapper;
import cn.changeHappy.exchange.mapper.ExchangeUserGoodsMapper;
import cn.changeHappy.exchange.pojo.SearchGoodsEntity;
import cn.changeHappy.exchange.servcie.ExchangeService;
import cn.changeHappy.exchange.utils.R;
import cn.changeHappy.exchange.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description: 告警配置service实现类
* @author: Duansx
* @date: Created in 2019/8/23 10:20
*/
@Service
public class ExchangeServiceImpl implements ExchangeService {
@Autowired
ExchangeOrderMapper exchangeOrderMapper;
@Autowired
ExchangeMapper exchangeMapper;
@Autowired
ExchangeUserGoodsMapper exchangeUserGoodsMapper;
@Override
public List<Map<String, Object>> selectChangeHappyBzdmAllType() throws Exception {
return exchangeMapper.selectChangeHappyBzdmAllType();
}
@Override
public List<Map<String, Object>> selectExchangeHomepageByGoodsType(Map<String, Object> map) {
return exchangeMapper.selectExchangeHomepageByGoodsType(map);
}
@Override
public List<Map<String, Object>> selectExchangeGoods(SearchGoodsEntity searchGoodsEntity) throws ParseException {
List<Map<String, Object>> list = exchangeMapper.selectExchangeGoods(searchGoodsEntity);
Map<String, Object> map=new HashMap<String, Object>();
map.put("userId",searchGoodsEntity.getUserId());
for (Map<String, Object> goodsMap : list) {
List<Map<String, Object>> fileList = exchangeMapper.selectFileByGoodsId(String.valueOf(goodsMap.get("id")));
goodsMap.put("fileList", fileList);
String crderTime = TimeUtil.QQFormatTime(goodsMap.get("crderTime").toString());
goodsMap.put("crderTime",crderTime);
//查询此商品是否收藏 collectionYes:1 收藏 2:没有收藏
map.put("goodsId",String.valueOf(goodsMap.get("id")));
int goodsCollectCount = exchangeUserGoodsMapper.selectGoodsByUserIdCnt(map);
if (goodsCollectCount > 0) {
goodsMap.put("collectionYes", true);
} else {
goodsMap.put("collectionYes", false);
}
}
return list;
}
@Override
public List<Map<String, Object>> queryTimeShopping() {
List<Map<String, Object>> list = exchangeMapper.queryTimeShopping();
for (Map<String, Object> goodsMap : list) {
List<Map<String, Object>> fileList = exchangeMapper.selectFileByGoodsId(String.valueOf(goodsMap.get("id")));
goodsMap.put("fileList", fileList);
}
return list;
}
@Override
public List<Map<String, Object>> queryPeopleVip(SearchGoodsEntity searchGoodsEntity) {
List<Map<String, Object>> list = exchangeMapper.queryPeopleVip(searchGoodsEntity);
Map<String, Object> map=new HashMap<String, Object>();
map.put("userId",searchGoodsEntity.getUserId());
for (Map<String, Object> goodsMap : list) {
List<Map<String, Object>> fileList = exchangeMapper.selectFileByGoodsId(String.valueOf(goodsMap.get("id")));
goodsMap.put("fileList", fileList);
//用户id和商品id 查询订单里是否参与活动
map.put("goodsId",goodsMap.get("goodsId"));
List<Map<String, Object>> activityList = exchangeOrderMapper.selectActivityOrderByUserIdGoodsId(map);
if (activityList.size() == 0) {
goodsMap.put("isPurchase", true);
} else {
goodsMap.put("isPurchase", false);
}
}
return list;
}
@Override
public List<Map<String, Object>> selectExchangeIndex() {
List<Map<String, Object>> list = exchangeMapper.selectExchangeIndex();
return list;
}
@Override
public List<Map<String, Object>> selectExchangeIndexHotGoods() {
return exchangeMapper.selectExchangeIndexHotGoods();
}
@Override
public Map<String, Object> selectExchangeCollectGoods(Map<String, Object> map) {
Map<String, Object> returnMap = new HashMap<>();
List<Map<String, Object>> objects = new ArrayList<>();
int count = exchangeMapper.selectExchangeCollectGoodsCount(map);
returnMap.put("collectCount", count);
if (count > 0) {
List<Map<String, Object>> goodsIdList = exchangeMapper.selectExchangeCollectGoodsList(map);
for (Map<String, Object> stringObjectMap : goodsIdList) {
String goodsId = String.valueOf(stringObjectMap.get("goodsId"));
Map<String, Object> goodsMap = exchangeMapper.selectGoodsByGoodsId(goodsId);
if (null != goodsMap) {
List<Map<String, Object>> fileList = exchangeMapper.selectFileByGoodsId(String.valueOf(goodsMap.get("id")));
if (fileList.size() > 0 && null != fileList) {
goodsMap.put("fileList", fileList);
} else {
goodsMap.put("fileList", new ArrayList<>());
}
objects.add(goodsMap);
}
}
}
returnMap.put("goodsList", objects);
returnMap.put("code",R.SUCCESS);
returnMap.put("msg","");
return returnMap;
}
@Override
public Map<String, Object> insertCollectGoods(Map<String, Object> map) throws Exception {
Map<String, Object> returnMap = new HashMap<>();
int count = exchangeMapper.insertCollectGoods(map);
if (count != 1) {
returnMap.put("code", R.ERROR);
returnMap.put("msg", "");
}
returnMap.put("code", R.SUCCESS);
returnMap.put("msg", "");
return returnMap;
}
@Override
public Map<String, Object> selectExchangeInform(String headlineType) throws Exception {
Map<String, Object> returnMap = new HashMap<>();
List<Map<String, Object>> informList = exchangeMapper.selectExchangeInform(headlineType);
returnMap.put("informList", informList);
return returnMap;
}
@Override
public List<Map<String, Object>> selectHomepageSlideshow() {
return exchangeMapper.selectHomepageSlideshow();
}
@Override
public List<Map<String, Object>> selectChangeHappyBzdmImg() throws Exception{
return exchangeMapper.selectChangeHappyBzdmImg();
}
@Override
public Map<String, Object> deleteGoodsByUserId(Map<String, Object> map) throws Exception{
Map<String, Object> returnMap = new HashMap<>();
int count = exchangeMapper.deleteGoodsByUserId(map);
if(count <=0){
returnMap.put("code", R.ERROR);
returnMap.put("msg", "");
}
returnMap.put("code", R.SUCCESS);
returnMap.put("msg", "");
return returnMap;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.changeHappy.exchange.mapper.ExchangeMapper" >
<select id="selectChangeHappyBzdmAllType" resultType="map">
select b.id,b.name,b.img,b.status from changehappy_type b where b.status='1'
</select>
<select id="selectExchangeHomepageByGoodsType" parameterType="map" resultType="map">
select * from changehappy_goods where goods_type=#{goodsType,jdbcType=INTEGER}
</select>
<select id="selectExchangeGoods" parameterType="cn.changeHappy.exchange.pojo.SearchGoodsEntity" resultType="map">
select
a.id,a.goods_id goodsId,
a.goods_name goodsName,
a.user_id userId ,a.goods_price goodsPrice,
a.goods_type goodsType,
a.crder_time crderTime,
a.sales,
b.name goodsTypeName,
b.img typeImg,
c.userImg userImg,
a.order_type_id orderTypeId,
a.page_view pageView,
a.goods_postage goodsPostage,
c.user_name userName,
a.goods_original_price goodsOriginalPrice
from changehappy_goods a
left join changehappy_type b on a.goods_type=b.id
left join changehappy_user c on a.user_id = c.user_id
where a.stand_up_and_down='1'
<if test="goodsType != null and goodsType != '' ">
and a.goods_type = #{goodsType,jdbcType=INTEGER}
</if>
<if test="sftj != null and sftj != ''">
and a.sftj = #{sftj,jdbcType=VARCHAR}
</if>
<if test="goodsName != null and goodsName != ''">
and a.goods_name like CONCAT('%',#{goodsName,jdbcType=VARCHAR}, '%')
</if>
<if test="orderTypeId != null and orderTypeId != ''">
and a.order_type_id = #{orderTypeId}
</if>
<if test="nearbyGoods != null and nearbyGoods != ''">
and state_id =#{nearbyGoods}
</if>
and a.goods_status='1'
and b.status ='1'
group by DATE_FORMAT(a.goods_time_recommend, '%Y/%m/%d %H:%i:%s'),a.id
order by DATE_FORMAT(a.crder_time, '%Y/%m/%d %H:%i:%s') desc
<if test="priceOder == 1">
, a.goods_price+0 desc
</if>
<if test="priceOder == 2">
, a.goods_price+0
</if>
<if test="insertOder != null and insertOder != ''">
, DATE_FORMAT(a.crder_time, '%Y/%m/%d %H:%i:%s') desc
</if>
<if test="pageView != null and pageView != ''">
, page_view desc
</if>
LIMIT #{currPage}, #{pageSize}
</select>
<select id="selectExchangeIndex" parameterType="map" resultType="map">
select a.id,a.navigation_name name,a.navigation_img img from changehappy_navigation a where a.navigation_status='1'
</select>
<select id="selectExchangeIndexHotGoods" resultType="map">
select id,goods_name goodsName,goods_id goodsId
from changehappy_hot_goods
</select>
<select id="selectExchangeCollectGoodsCount" parameterType="map" resultType="int">
select count(*) userCount from changehappy_collect_goods where user_id = #{userId,jdbcType=VARCHAR}
</select>
<select id="selectExchangeCollectGoodsList" parameterType="map" resultType="map">
select goods_id goodsId from changehappy_collect_goods where user_id = #{userId,jdbcType=VARCHAR}
</select>
<select id="selectGoodsByGoodsId" parameterType="string" resultType="map">
select
a.id,a.goods_id goodsId,
a.goods_name goodsName,
a.user_id userId ,a.goods_price goodsPrice,
a.goods_type goodsType,
a.sales,
b.name goodsTypeName,
b.img typeImg,
u.user_name userName,
u.userImg
from changehappy_goods a
left join changehappy_user u on a.user_id = u.user_id
left join changehappy_type b on a.goods_type=b.id
where a.id =#{goodsId}
</select>
<insert id="insertCollectGoods" parameterType="map">
insert into changehappy_collect_goods(user_id,goods_id)
values
(#{userId,jdbcType=VARCHAR},#{goodsId})
</insert>
<select id="selectExchangeInform" parameterType="string" resultType="map">
select id,headline_name headlineName,content_txt contentTxt,goods_id goodsId,headline_type headlineType
from changehappy_inform where headline_type=#{headlineType}
</select>
<select id="selectHomepageSlideshow" resultType="map">
select id,banner_url bannerUrl,banner_type bannerType,banner_status bannerStatus,banner_jump_address bannerJumpAddress from changehappy_banner where banner_status='1'
</select>
<select id="selectChangeHappyBzdmImg" resultType="map">
select BZDM bzdm,DM dm,BZ bz,DICT_TYPE dtctType from changehappy_bzdm where BZDM='homeImg'
</select>
<select id="selectFileByGoodsId" parameterType="string" resultType="map">
select id,file_url goodsImg ,goods_id goodsId from changehappy_file where goods_id=#{id}
</select>
<delete id="deleteGoodsByUserId" parameterType="map">
delete from changehappy_collect_goods where user_id = #{userId} and goods_id =#{goodsId}
</delete>
<select id="selectUserAttention" parameterType="map" resultType="int">
select count(*) from changehappy_attention where user_id =#{userId} and attention_id=#{attentionId} and status ='1'
</select>
<select id="queryTimeShopping" resultType="map">
select
a.id,a.goods_id goodsId,
a.goods_name goodsName,
a.user_id userId ,a.goods_price goodsPrice,
a.goods_type goodsType,
a.crder_time crderTime,
a.sales,
a.order_type_id orderTypeId,
a.page_view pageView,
a.goods_postage goodsPostage,
a.goods_original_price goodsOriginalPrice
from changehappy_goods a
where a.stand_up_and_down='1'
and a.goods_status='1'
and is_timeShopping = '1'
</select>
<select id="queryPeopleVip" parameterType="cn.changeHappy.exchange.pojo.SearchGoodsEntity" resultType="map">
select
a.id,a.goods_id goodsId,
a.goods_name goodsName,
a.user_id userId ,a.goods_price goodsPrice,
a.goods_type goodsType,
a.crder_time crderTime,
a.sales,
a.order_type_id orderTypeId,
a.page_view pageView,
a.goods_postage goodsPostage,
a.goods_original_price goodsOriginalPrice,
a.activity_status activityStatus
from changehappy_goods a
where a.stand_up_and_down='1'
and a.goods_status='1'
and a.order_type_id='4'
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.changeHappy.exchange.mapper.ExchangeOrderMapper" >
<select id="selectOrderByUserId" parameterType="map" resultType="map">
SELECT
a.order_status orderStatus,
a.seller_user_id sellerUserId,
a.order_type orderType,
a.order_id orderId,
b.user_name userName,
b.user_id userId,
c.goods_name goodsName,
d.user_name orderUserName,
c.goods_price goodsPrice,
a.date_time orderTime,
a.payment_type paymentType,
a.goods_id goodsId,
e.refuse_reason refuseReason,
a.wx_order_id wxOrderId,
a.user_site_id userSiteId,
c.goods_postage goodsPostage,
a.seller_goods_name sellerGoodsName,
a.express_status expressStatus,
a.update_time updateTime
FROM
changehappy_order a
LEFT JOIN changehappy_user b ON a.user_id = b.user_id
LEFT JOIN changehappy_goods c ON a.goods_id = c.id
LEFT JOIN changehappy_user d ON c.user_id = d.user_id
LEFT JOIN changehappy_sales_return e ON a.order_id = e.order_id
WHERE
a.user_id = #{userId,jdbcType=VARCHAR} and a.sfky='1'
<if test="orderStatus == '100'.toString()">
and a.order_status in ('4','5','6')
</if>
<if test="orderStatus != '' and orderStatus != null and orderStatus != '100'.toString()">
and a.order_status=#{orderStatus,jdbcType=VARCHAR}
</if>
<if test="orderType !='' and orderType != null ">
and a.order_type =#{orderType}
</if>
<if test="orderType == '1'.toString()">
and a.order_status !='1'
</if>
order by DATE_FORMAT(a.date_time, '%Y/%m/%d %H:%i:%s') desc
LIMIT #{currPage}, #{pageSize}
</select>
<select id="selectSellerOrderByUserId" parameterType="map" resultType="map">
SELECT
a.order_status orderStatus,
a.seller_user_id sellerUserId,
a.order_type orderType,
a.order_id orderId,
b.user_name userName,
b.user_id userId,
c.goods_name goodsName,
d.user_name orderUserName,
c.goods_price goodsPrice,
a.date_time orderTime,
a.payment_type paymentType,
a.goods_id goodsId,
e.refuse_reason refuseReason,
a.wx_order_id wxOrderId,
a.user_site_id userSiteId,
c.goods_postage goodsPostage,
a.seller_goods_name sellerGoodsName,
a.express_status expressStatus
FROM
changehappy_order a
LEFT JOIN changehappy_user b ON a.user_id = b.user_id
LEFT JOIN changehappy_goods c ON a.goods_id = c.id
LEFT JOIN changehappy_user d ON c.user_id = d.user_id
LEFT JOIN changehappy_sales_return e ON a.order_id = e.order_id
WHERE
a.seller_user_id = #{sellerUserId,jdbcType=VARCHAR} and a.sfky='1'
<if test="orderStatus == '100'.toString()">
and a.order_status in ('4','5','6')
</if>
<if test="orderStatus != '' and orderStatus != null and orderStatus != '100'.toString()">
and a.order_status=#{orderStatus,jdbcType=VARCHAR}
</if>
<if test="orderType !='' and orderType != null ">
and a.order_type =#{orderType}
</if>
<if test="orderType == '1'.toString()">
and a.order_status !='1'
</if>
order by DATE_FORMAT(a.date_time, '%Y/%m/%d %H:%i:%s') desc
LIMIT #{currPage}, #{pageSize}
</select>
<select id="selectSellerByUserId" parameterType="map" resultType="map">
select a.order_status orderStatus,
a.order_type orderType,
a.order_id orderId,
a.user_site_id userSiteId,
b.user_id userId,
b.user_name userName,
c.goods_name goodsName,
d.user_name orderUserName,
c.goods_price goodsPrice,
a.date_time orderTime,
a.payment_type paymentType,
a.goods_id goodsId,
e.return_reason returnReason,
e.return_info returnInfo,
a.wx_order_id wxOrderId,
a.express_status expressStatus
from changehappy_order a
left join changehappy_user b on a.user_id =b.user_id
left join changehappy_goods c on a.goods_id = c.id
left join changehappy_user d on c.user_id = d.user_id
left join changehappy_sales_return e on a.order_id = e.order_id
where a.seller_user_id=#{sellerUserId,jdbcType=VARCHAR}
<if test="orderStatus == '100'.toString()">
and a.order_status in ('4','5','6')
</if>
<if test="orderStatus != '' and orderStatus != null and orderStatus != '100'.toString()">
and a.order_status=#{orderStatus,jdbcType=VARCHAR}
</if>
<if test="orderType != '' and orderType != null ">
and a.order_type =#{orderType,jdbcType=VARCHAR}
</if>
LIMIT #{currPage}, #{pageSize}
</select>
<select id="selectFileByGoodsId" parameterType="string" resultType="map">
select id,file_url goodsImg ,goods_id goodsId from changehappy_file where goods_id=#{id}
</select>
<insert id="insertUser" parameterType="cn.changeHappy.exchange.pojo.ChangehappyRecord">
insert into changehappy_order
(user_id,goods_id,date_time,remark,order_status,order_type,order_id,
seller_user_id,goods_name,goods_price,user_site_id,payment_type,exchange_goods_id,site_exchange_user,seller_goods_name)
values
(#{userId,jdbcType=VARCHAR},
#{goodsId},
now(),
#{remark,jdbcType=VARCHAR},
#{orderStatus},
#{orderType,jdbcType=VARCHAR},
#{orderId,jdbcType=VARCHAR},
#{sellerUserId,jdbcType=VARCHAR},
#{goodsName,jdbcType=VARCHAR},
#{goodsPrice,jdbcType=VARCHAR},
#{userSiteId,jdbcType=VARCHAR},
#{paymentType},
#{exchangeGoodsId},
#{siteExchangeUser},
#{sellerGoodsName})
</insert>
<!-- 被交换人订单 -->
<insert id="insertExchangePersonOrder" parameterType="cn.changeHappy.exchange.pojo.ChangehappyRecord">
insert into changehappy_order
(user_id,goods_id,date_time,remark,order_status,order_type,order_id,
seller_user_id,goods_name,goods_price,user_site_id,payment_type,exchange_goods_id,site_exchange_user,seller_goods_name)
values
(#{sellerUserId,jdbcType=VARCHAR},
#{goodsId},
now(),
#{remark,jdbcType=VARCHAR},
#{orderStatus},
#{orderType,jdbcType=VARCHAR},
#{orderId,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR},
#{goodsName,jdbcType=VARCHAR},
#{goodsPrice,jdbcType=VARCHAR},
#{userSiteId,jdbcType=VARCHAR},
#{paymentType},
#{exchangeGoodsId},
#{siteExchangeUser},
#{sellerGoodsName})
</insert>
<update id="updateOrderStatus" parameterType="map" >
update changehappy_order
set order_status =#{orderStatus} ,
update_time =#{updateTime} ,
wx_order_id =#{wxOrderId}
where order_id =#{orderId}
</update>
<select id="selectGoodsByGoodsId" parameterType="string" resultType="map">
select a.id goodsId,a.goods_name goodsName,a.user_id userId,a.goods_brief goodsBrief,
b.user_name userName,b.userImg userImg,a.goods_price goodsPrice,
a.sales,
c.MC goodsTypeName,
a.order_type_id orderTypeId,
a.page_view pageView,
a.activity_status activityStatus
from changeHappy_goods a
left join changehappy_user b on a.user_id = b.user_id
left join changehappy_bzdm c on a.goods_type =c.ID
left join changehappy_file f on a.goods_id = f.goods_id
where a.id=#{goodsId}
</select>
<update id="updateChangehappyGoods" parameterType="cn.changeHappy.exchange.pojo.InsertUserGoodsEntity">
update changeHappy_goods
set
goods_name=#{goodsName,jdbcType=VARCHAR},user_id=#{userId},
goods_type=#{goodsType,jdbcType=INTEGER},
crder_time=#{crderTime},
goods_status=#{goodsStatus},
order_type_id=#{orderTypeId}
where id=#{goodsId}
</update>
<insert id="saveOrderInfo" parameterType="cn.changeHappy.exchange.pojo.ChangeHappyOrderInfo">
insert into changehappy_order_info
(id,user_id,exchange_id,status,crder_time,apply_count,goods_id,exchange_goods_id,sfky)
values
(#{id},#{userId},#{exchangeId},#{status},#{crderTime},#{applyCount},#{goodsId},#{exchangeGoodsId},'1')
</insert>
<update id="updateOrderInfo" parameterType="cn.changeHappy.exchange.pojo.ChangeHappyOrderInfo">
update changehappy_order_info set
user_id=#{userId},
exchange_id=#{exchangeId},
status=#{status},
apply_count=#{applyCount},
goods_id=#{goods_id},
exchange_goods_id=#{exchangeGoodsId}
where id =#{id}
</update>
<select id="selectOrderInfo" parameterType="cn.changeHappy.exchange.pojo.ChangeHappyOrderInfo">
select id,user_id,exchange_id,status,crder_time,apply_count,goods_id,exchange_goods_id
from changehappy_order_info
where sfky='1'
<if test="seleType != null and seleType !='' and seleType =='1'.toString()">
and user_id =#{userId}
</if>
<if test="seleType != null and seleType !='' and seleType == '2'.toString()">
and exchange_id =#{userId}
</if>
order by DATE_FORMAT(crder_time, '%Y/%m/%d %H:%i:%s') desc
</select>
<select id="selectOrderByOrderId" parameterType="string" resultType="map" >
select a.seller_user_id sellerUserId,a.order_status orderStatus,a.order_type orderType,a.order_count orderCount,a.order_id orderId,
b.user_name userName,c.goods_name goodsName,d.user_name orderUserName,b.user_id userId,
c.goods_price goodsPrice,a.date_time orderTime,a.payment_type paymentType,a.goods_id goodsId,
a.site_exchange_user siteExchangeUser,a.date_time crderTime,a.user_site_id userSiteId
from changehappy_order a
left join changehappy_user b on a.user_id =b.user_id
left join changehappy_goods c on a.goods_id = c.id
left join changehappy_user d on c.user_id = d.user_id
where a.order_id=#{outTradeNo,jdbcType=VARCHAR}
</select>
<!--查询换换订单 queryChangeOrder-->
<select id="queryChangeOrder" parameterType="string" resultType="map" >
select a.seller_user_id sellerUserId,a.order_status orderStatus,a.order_type orderType,a.order_count orderCount,a.order_id orderId,
b.user_name userName,c.goods_name goodsName,d.user_name orderUserName,b.user_id userId,
c.goods_price goodsPrice,a.date_time orderTime,a.payment_type paymentType,a.goods_id goodsId,
a.site_exchange_user siteExchangeUser,a.date_time crderTime,a.user_site_id userSiteId
from changehappy_order a
left join changehappy_user b on a.user_id =b.user_id
left join changehappy_goods c on a.goods_id = c.id
left join changehappy_user d on c.user_id = d.user_id
where a.order_id=#{outTradeNo,jdbcType=VARCHAR} and a.user_id=#{userId,jdbcType=VARCHAR}
</select>
<insert id="insertOrderLog" parameterType="map" >
insert into changehappy_order_log
(id,order_id,wx_order_id,payment_type,goods_id,user_id,crder_time,log_type,user_money,user_reeze_money)
values
(#{id},#{orderId},#{wxOrderId},#{paymentType},#{goodsId},#{userId},#{crderTime},#{logType},#{userMoney},#{userReezeMoney})
</insert>
<select id="selectUserByUserId" parameterType="string" resultType="string">
select user_name userName from changehappy_user where user_id =#{userId}
</select>
<insert id="insertActivityByUserIdGoodsId" parameterType="map">
insert into changehappy_activity
(id,user_id,goods_id)
values
(#{id},#{userId},#{goodsId})
</insert>
<select id="selectActivityOrderByUserIdGoodsId" parameterType="map" resultType="map">
select id,order_id
from changehappy_order
where user_id=#{userId}
and goods_id =#{goodsId}
</select>
<insert id="saveSalesReturn" parameterType="map">
insert into changehappy_sales_return
(id,whether_goods,return_reason,return_info,order_id,return_status)
values
(#{id},#{whetherGoods},#{returnReason},#{returnInfo},#{orderId},#{returnStatus})
</insert>
<update id="updateSalesReturn" parameterType="map">
update changehappy_sales_return
set
refuse_reason=#{refuseReason},
return_status=#{returnStatus}
where order_id=#{orderId}
</update>
<update id="updateOrderByOrderId" parameterType="cn.changeHappy.exchange.pojo.ChangehappyRecord" >
update changehappy_order
set order_status=#{orderStatus},
update_time =#{updateTime}
where order_id =#{orderId} and user_id =#{userId}
</update>
<update id="updateSellerOrderStatus" parameterType="cn.changeHappy.exchange.pojo.ChangehappyRecord" >
update changehappy_order
set order_status=#{orderStatus},
update_time =#{updateTime}
where order_id =#{orderId} and user_id =#{sellerUserId}
</update>
<update id="updateOrderStatusByOrderId" parameterType="map" >
update changehappy_order
set order_status='0',
update_time =#{updateTime}
where order_id =#{orderId}
</update>
<select id="selectOrderByUserIdList" parameterType="map" resultType="map">
SELECT
a.order_status orderStatus,
a.seller_user_id sellerUserId,
a.order_type orderType,
a.order_id orderId,
b.user_id userId,
c.goods_name goodsName,
c.goods_price goodsPrice,
a.date_time orderTime,
a.payment_type paymentType,
a.goods_id goodsId,
e.refuse_reason refuseReason,
a.wx_order_id wxOrderId,
a.user_site_id userSiteId,
c.goods_postage goodsPostage,
a.seller_goods_name sellerGoodsName,
a.express_status expressStatus,
a.update_time updateTime
FROM
changehappy_order a
LEFT JOIN changehappy_user b ON a.user_id = b.user_id
LEFT JOIN changehappy_goods c ON a.goods_id = c.id
LEFT JOIN changehappy_user d ON c.user_id = d.user_id
LEFT JOIN changehappy_sales_return e ON a.order_id = e.order_id
WHERE
a.seller_user_id = #{userId,jdbcType=VARCHAR} and a.sfky='1'
and a.order_status ='3'
</select>
</mapper>
|