d0afcb9f 刘嘉

菠萝派接口- 修改订单备注、发货、商品下载调用新数据源

1 个父辈 f06dcfdb
package com.sibu.orderHelper.mall.member.read;
import com.sibu.orderHelper.integral.model.DownloadProductBean;
import com.sibu.orderHelper.integral.model.DownloadProductSkuBean;
import com.sibu.orderHelper.integral.model.IMSupplierApp;
import com.sibu.orderHelper.integral.pineapple.model.*;
import com.sibu.orderHelper.integral.reponse.MemberAddressResponse;
import com.sibu.orderHelper.integral.request.MemberAddressAddRequest;
import org.apache.ibatis.annotations.Param;
......@@ -9,4 +13,111 @@ import java.util.Map;
public interface MemberReadDao {
Integer count();
IMSupplierApp findByAppIdAndAppType(Map<String, String> params);
/**
* 根据订单号查询订单信息 只查询不是主订单的订单
* @param params
* @return
*/
Orders getOrdersByMap(Map<String,Object> params);
/**
* 查询该订单是否有该快递单号
* @param params
* @return
*/
int checkLogisticsNumber(Map<String,Object> params);
/**
* 商品下载
* @param params
* @return
*/
List<DownloadProductBean> downloadProductListByMap(Map<String,Object> params);
/**
* 商品下载总数量
* @param params
* @return
*/
int countDownloadProductListByMap(Map<String,Object> params);
/**
* 根据条件查询商品
* @param params
* @return
*/
DownloadProductBean getDownloadProductBeanByMap(Map<String,Object> params);
/**
* 根据商品ID获取该商品的所有SKU
* @param productId
* @return
*/
List<DownloadProductSkuBean> downloadSkuByProductId(@Param("productId") String productId);
/**
* 订单下载
* @param params
* @return
*/
List<Orders> getOrdersList(Map<String,Object> params);
/**
* 子订单查询
* @param orderSn
* @return
*/
List<OrdersProduct> getOrdersProductList(@Param("orderSn")String orderSn);
/**
* 根据条件查询省市级信息
* @param params
* @return
*/
List<Regions> getRegionsByMap(Map<String,Object> params);
/**
* 根据id查询省市级信息
* @param id
* @return
*/
Regions getRegionsById(@Param("id") Integer id);
/**
* 根据条件查询物流公司
* @return
*/
List<CourierCompany> getCourierCompanyByName(Map<String,Object> params);
/**
* 根据订单号查询退货信息
* @param orderSn
* @return
*/
List<MemberProductBack> getMemberProductBackByOrderSn(@Param("orderSn") String orderSn);
/**
* 根据订单号查询换货信息
* @param orderSn
* @return
*/
List<MemberProductExchange> getMemberProductExchangeByOrderSn(@Param("orderSn") String orderSn);
/**
* 根据订单ID查询投诉表
* @param id
* @return
*/
List<SellerComplaint> getSellerComplaintByOrderId(@Param("orderId") Integer id);
List<Seller> getSeller(@Param("id") String id);
}
......
package com.sibu.orderHelper.mall.member.write;
import java.util.Map;
public interface MemberWriteDao {
Integer count();
/**
* 修改订单备注
* @param params
* @return
*/
int updateOdersRemark(Map<String,Object> params);
/**
* 订单发货更新订单状态与信息
* @param params
* @return
*/
int updateOrdersState(Map<String,Object> params);
/**
* 根据条件更新sku库存
* @param params
* @return
*/
int updateSkuStock(Map<String,Object> params);
/**
* 根据商品ID更新商品库存
* @param params
* @return
*/
int updateProductStock(Map<String,Object> params);
}
......
......@@ -14,6 +14,7 @@ import com.sibu.orderHelper.integral.model.IMSupplier;
import com.sibu.orderHelper.integral.model.IMSupplierApp;
import com.sibu.orderHelper.integral.pineapple.enums.SubErrorEnum;
import com.sibu.orderHelper.integral.pineapple.exception.BizException;
import com.sibu.orderHelper.integral.pineapple.model.Seller;
import com.sibu.orderHelper.integral.pineapple.request.BaseRequest;
import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.pineapple.response.BaseResponse;
......@@ -27,6 +28,7 @@ import com.sibu.orderHelper.integral.service.pineapple.BizService;
import com.sibu.orderHelper.integral.service.pineapple.util.JsonUtils;
import com.sibu.orderHelper.integral.pineapple.constant.PineAppleConst;
import com.sibu.orderHelper.integral.service.pineapple.util.XmlUtils;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import net.sf.json.JSONObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -67,6 +69,8 @@ public class PineappleController {
private IMSupplierAppService imSupplierAppService;
@Autowired
private IMSupplierDao imSupplierDao;
@Resource
private MemberReadDao memberReadDao;
@RequestMapping(
value = "/pineapple/call",
......@@ -169,14 +173,19 @@ public class PineappleController {
}
private IMSupplier findAndCheckIMSupplier(BaseRequest request, IMSupplierApp imSupplierApp) {
List<IMSupplier> imSuppliers = imSupplierDao.findByIdIn(Arrays.asList(imSupplierApp.getSupplierId()));
if (CollectionUtils.isEmpty(imSuppliers)) {
//List<IMSupplier> imSuppliers = imSupplierDao.findByIdIn(Arrays.asList(imSupplierApp.getSupplierId()));
List<Seller> seller = memberReadDao.getSeller(imSupplierApp.getSupplierId());
if (CollectionUtils.isEmpty(seller)) {
throw new BizException(MessageFormat.format("appKey【{0}】的店铺数据为空,请联系客服", request.getAppkey()));
}
if (imSuppliers.size() > 1) {
if (seller.size() > 1) {
throw new BizException(MessageFormat.format("appKey【{0}】的店铺数据有重复,请联系客服", request.getAppkey()));
}
return imSuppliers.get(0);
Seller entity = seller.get(0);
IMSupplier iMSupplier = new IMSupplier();
iMSupplier.setId(String.valueOf(entity.getId()));
iMSupplier.setName(entity.getName());
return iMSupplier;
}
private IMSupplierApp findAndCheckSupplierApp(BaseRequest request) {
......
......@@ -7,4 +7,68 @@
<select id="count" resultType="java.lang.Integer">
select count(*) from member
</select>
<!-- 修改订单备注 -->
<update id="updateOdersRemark" parameterType="java.util.Map">
UPDATE orders SET remark = #{remark},update_time = now() WHERE order_sn = #{orderSn} AND seller_id = #{sellerId}
</update>
<!--更改订单状态、电话、地址、发货时间、收货人姓名,快递单号 -->
<update id="updateOrdersState">
UPDATE orders
<set>
<if test="name !=null and name !=''">
name = #{name},
</if>
<if test="addressInfo !=null and addressInfo !=''">
address_info = #{addressInfo},
</if>
<if test="logisticsNumber !=null and logisticsNumber !=''">
logistics_number = #{logisticsNumber},
</if>
<if test="mobile !=null and mobile !=''">
mobile = #{mobile},
</if>
<if test="addressAll !=null and addressAll !=''">
address_all = #{addressAll},
</if>
<if test="orderState !=null and orderState !=''">
order_state = #{orderState},
</if>
<if test="provinceId !=null and provinceId !=''">
province_id = #{provinceId},
</if>
<if test="areaId !=null and areaId !=''">
area_id = #{areaId},
</if>
<if test="cityId !=null and cityId !=''">
city_id = #{cityId},
</if>
<if test="deliverTime !=null and deliverTime !=''">
deliver_time = now(),
</if>
<if test="logisticsName !=null and logisticsName !=''">
logistics_name = #{logisticsName},
</if>
<if test="logisticsId !=null and logisticsId !=''">
logistics_id = #{logisticsId},
</if>
update_time = now()
</set>
WHERE order_sn = #{orderSn} AND seller_id = #{sellerId}
</update>
<!-- 更新SKU库存-->
<update id="updateSkuStock" parameterType="java.util.Map">
UPDATE product_goods SET product_stock = #{stock} WHERE sku = #{skuId} and product_id = #{productId}
</update>
<!-- 更新产品库存-->
<update id="updateProductStock" parameterType="java.util.Map">
UPDATE product SET product_stock = #{productStock} WHERE id = #{productId}
</update>
</mapper>
\ No newline at end of file
......
......@@ -3,13 +3,14 @@ package com.sibu.orderHelper.integral.pineapple.model;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
@ToString
public class Orders {
public class Orders implements Serializable{
private Integer id;
private String orderSn;
private String orderPsn;
......@@ -68,7 +69,7 @@ public class Orders {
private String codconfirmRemark;
private Integer codconfirmState;
private String createTime;
private String DateupdateTime;
private String updateTime;
private Integer evaluateState;
private String regionName1;
private String regionName2;
......
package com.sibu.orderHelper.integral.pineapple.model;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
@ToString
public class Seller implements Serializable{
private Integer id; //id
private Integer memberId; //用户ID
private String name; //用户名
private String sellerName; //店铺名称
private String sellerLogo; //店铺logo
private Integer sellerGrade; //店铺等级
private String scoreService; //店铺评分服务
private String scoreDeliverGoods; //店铺评分发货
private String scoreDescription; //店铺评分描述
private Integer productNumber; //商品数量
private Integer collectionNumber; //店铺收藏
private Date createTime; //创建时间
private BigDecimal saleMoney; //店铺总销售金额
private Integer orderCount; //店铺总订单量
private Integer orderCountOver; //店铺完成订单量
private String sellerKeyword; //SEO关键字
private String sellerDes; //SEO店铺描述
private Integer auditStatus; //审核状态 1、待审核;2、审核通过;3、冻结
private String storeSlide;
}
......@@ -6,9 +6,11 @@ import com.sibu.orderHelper.integral.dao.IMSupplierAppDao;
import com.sibu.orderHelper.integral.model.IMSupplierApp;
import com.sibu.orderHelper.integral.pineapple.request.BaseRequest;
import com.sibu.orderHelper.integral.service.IMSupplierAppService;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
......@@ -23,6 +25,9 @@ public class IMSupplierAppServiceImpl implements IMSupplierAppService {
@Autowired
private IMSupplierAppDao imSupplierAppDao;
@Resource
private MemberReadDao memberReadDao;
@Override
public IMSupplierApp findByAppIdAndAppType(String appId, SupplierAppTypeEnum appType) {
Map<String, String> params = new HashMap<>();
......@@ -37,6 +42,6 @@ public class IMSupplierAppServiceImpl implements IMSupplierAppService {
params.put("appId", requestParams.getAppkey());
params.put("appToken", requestParams.getToken());
params.put("appType", appType.getCode());
return imSupplierAppDao.findByAppIdAndAppType(params);
return memberReadDao.findByAppIdAndAppType(params);
}
}
......
......@@ -10,6 +10,7 @@ import com.sibu.orderHelper.integral.model.DownloadProductSkuBean;
import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.reponse.DownloadProductResponse;
import com.sibu.orderHelper.integral.request.DownloadProductRequest;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
......@@ -23,13 +24,13 @@ public class DownloadProductBizServiceImpl extends AbstractBizService<DownloadP
private static Logger log = Logger.getLogger(DownloadProductBizServiceImpl.class);
@Resource
private PineappleDao pineappleDao;
private MemberReadDao memberReadDao;
@Override
public DownloadProductResponse call(CallRequest<DownloadProductRequest> callRequest) throws Exception {
DownloadProductResponse downloadProductResponse = new DownloadProductResponse();
Map<String,Object> params =new HashMap<>();
params.put("supplierId",callRequest.getSupplier().getId());
params.put("sellerId",callRequest.getSupplier().getId());
if(!StringUtil.isNull(callRequest.getBizModel().getStatus())){
params.put("state", DownloadProductStatusEnum.resolve(callRequest.getBizModel().getStatus()).intValue());
}
......@@ -42,14 +43,15 @@ public class DownloadProductBizServiceImpl extends AbstractBizService<DownloadP
params.put("productName",callRequest.getBizModel().getPageSize());
}
//查询产品
List<DownloadProductBean> downloadProductBeanList = pineappleDao.downloadProductListByMap(params);
List<DownloadProductBean> downloadProductBeanList = memberReadDao.downloadProductListByMap(params);
if(!StringUtil.isNull(downloadProductBeanList) && !downloadProductBeanList.isEmpty()){
for(DownloadProductBean product : downloadProductBeanList){
//产品SKU
List<DownloadProductSkuBean> downloadProductSkuBeanList = pineappleDao.downloadSkuByProductId(product.getPlatProductID());
List<DownloadProductSkuBean> downloadProductSkuBeanList = memberReadDao.downloadSkuByProductId(product.getPlatProductID());
product.setSkus(downloadProductSkuBeanList);
};
downloadProductResponse.setTotalcount(downloadProductBeanList.size());
int count = memberReadDao.countDownloadProductListByMap(params);
downloadProductResponse.setTotalcount(count);
}else{
downloadProductResponse.setTotalcount(0);
}
......
......@@ -17,6 +17,8 @@ import com.sibu.orderHelper.integral.pineapple.model.Regions;
import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.pineapple.response.BaseResponse;
import com.sibu.orderHelper.integral.request.PineappleSendRequest;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import com.sibu.orderHelper.mall.member.write.MemberWriteDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
......@@ -28,7 +30,9 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
private static Logger log = Logger.getLogger(PineappleSendBizServiceImpl.class);
@Resource
private PineappleDao pineappleDao;
private MemberReadDao memberReadDao;
@Resource
private MemberWriteDao memberWriteDao;
@Override
public BaseResponse call(CallRequest<PineappleSendRequest> callRequest) throws Exception {
......@@ -37,7 +41,7 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
params.put("orderSn",callRequest.getBizModel().getPlatOrderNo());
params.put("sellerId",callRequest.getSupplier().getId());
Orders orders = pineappleDao.getOrdersByMap(params);
Orders orders = memberReadDao.getOrdersByMap(params);
if(StringUtil.isNull(orders)){
log.error(String.format("订单发货,获取订单数据业务异常:[%s]",callRequest.getBizModel().getPlatOrderNo()));
throw new BizException(String.format("订单发货,获取订单数据业务异常:[%s]",callRequest.getBizModel().getPlatOrderNo()));
......@@ -65,7 +69,7 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
if(!StringUtil.isNull(callRequest.getBizModel().getLogisticNo())){
//判断该快递订单号是否存在,已存在就不允许把该快递订单号添加进去
int num = pineappleDao.checkLogisticsNumber(params);
int num = memberReadDao.checkLogisticsNumber(params);
if(num == 0){
if(StringUtil.isNull(orders.getLogisticsNumber())){
params.put("logisticsNumber",callRequest.getBizModel().getLogisticNo());
......@@ -80,7 +84,7 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
throw new BizException(String.format("订单发货接口,该订单状态不允许进行发货操作,订单号:[%s]",callRequest.getBizModel().getPlatOrderNo()));
}
//修改订单信息
pineappleDao.updateOrdersState(params);
memberWriteDao.updateOrdersState(params);
baseResponse.setMessage(PineappleEnum.SUCCESS.getMsg());
baseResponse.setCode(PineappleEnum.SUCCESS.getCode());
return baseResponse;
......@@ -102,17 +106,17 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
Map<String,Object> map = new HashMap<>();
map.put("regionType",3);
map.put("name",str[2]);
Regions regions = pineappleDao.getRegionsByMap(map);
if(StringUtil.isNull(regions)){
List<Regions> regions = memberReadDao.getRegionsByMap(map);
if(StringUtil.isNull(regions) || regions.size() > 1){
params.put("provinceId","99999990");
params.put("cityId", "99999989");
params.put("areaId","99999988");
}else{
params.put("area",regions.getId());
Regions city = pineappleDao.getRegionsById(regions.getId());
params.put("area",regions.get(0).getId());
Regions city = memberReadDao.getRegionsById(regions.get(0).getId());
Regions province = null;
if(!StringUtil.isNull(city)){
province = pineappleDao.getRegionsById(city.getId());
province = memberReadDao.getRegionsById(city.getId());
}
if(!StringUtil.isNull(city) && !StringUtil.isNull(province)){
params.put("provinceId", province.getId());
......@@ -133,8 +137,8 @@ public class PineappleSendBizServiceImpl extends AbstractBizService<PineappleSen
Map<String,Object> m = new HashMap<>();
m.put("name","orders.getLogisticsName()");
m.put("sellerId",callRequest.getSupplier().getId());
List<CourierCompany> courierCompanyByName = pineappleDao.getCourierCompanyByName(m);
if(!StringUtil.isNull(courierCompanyByName) && !courierCompanyByName.isEmpty()){
List<CourierCompany> courierCompanyByName = memberReadDao.getCourierCompanyByName(m);
if(!StringUtil.isNull(courierCompanyByName) && !courierCompanyByName.isEmpty() && courierCompanyByName.size() == 1){
Optional<CourierCompany> first = courierCompanyByName.stream().findFirst();
params.put("logisticsName",callRequest.getBizModel().getLogisticName());
params.put("logisticsId", first.get().getId());
......
......@@ -13,8 +13,11 @@ import com.sibu.orderHelper.integral.pineapple.model.Orders;
import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.reponse.UpdateSellerMemoResponse;
import com.sibu.orderHelper.integral.request.UpdateSellerMemoRequest;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import com.sibu.orderHelper.mall.member.write.MemberWriteDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
......@@ -24,22 +27,25 @@ public class UpdateSellerMemoBizServiceImpl extends AbstractBizService<UpdateS
private static Logger log = Logger.getLogger(UpdateSellerMemoBizServiceImpl.class);
@Resource
private MemberReadDao memberReadDao;
@Resource
private PineappleDao pineappleDao;
private MemberWriteDao memberWriteDao;
@Override
public UpdateSellerMemoResponse call(CallRequest<UpdateSellerMemoRequest> callRequest) throws Exception {
UpdateSellerMemoResponse UpdateSellerMemoResponse =new UpdateSellerMemoResponse();
Map<String,Object> params = new HashMap<>();
params.put("orderSn ",callRequest.getBizModel().getPlatOrderNo());
params.put("remark ",callRequest.getBizModel().getSellerMemo());
params.put("orderSn",callRequest.getBizModel().getPlatOrderNo());
params.put("remark",callRequest.getBizModel().getSellerMemo());
params.put("sellerId",callRequest.getSupplier().getId());
Orders orders = pineappleDao.getOrdersByMap(params);
Orders orders = memberReadDao.getOrdersByMap(params);
if(StringUtil.isNull(orders)){
log.error(String.format("修改订单备注,获取订单数据业务异常,订单号:[%s]",callRequest.getBizModel().getPlatOrderNo()));
throw new BizException(String.format("修改订单备注,获取订单数据业务异常,订单号:[%s]",callRequest.getBizModel().getPlatOrderNo()));
}
if(pineappleDao.updateOdersRemark(params) != 1){
if(memberWriteDao.updateOdersRemark(params) != 1){
log.error(String.format("修改订单备注,修改失败,订单号:[%s]",callRequest.getBizModel().getPlatOrderNo()));
throw new BizException(String.format("修改订单备注,修改失败,订单号:[%s]",callRequest.getBizModel().getPlatOrderNo()));
}
......