提交 2562f5d4 authored 作者: 李秋林's avatar 李秋林

打卡照片更改,选择商品类型可根据69码扫描,同步勤策数据到表

上级 46ad7041
package com.wangxiaolu.promotion.controller.user.qince;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.CascadeVo;
import com.wangxiaolu.promotion.pojo.user.dto.QinceProductInfoDto;
import com.wangxiaolu.promotion.pojo.user.dto.QinceProductTypeDto;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.user.QinCeProductQueryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-06-19 17
* @describe :
* @describe : 商品信息查询
*/
@RestController
@RequestMapping("/user/qince/query")
......@@ -24,18 +30,37 @@ public class QinCeProductQueryController {
QinCeProductQueryService qinCeProductQueryService;
@PostMapping("/product/type/list")
public R findProductTypeList(){
public R findProductTypeList() {
List<QinceProductTypeDto> dtos = qinCeProductQueryService.findProductTypeList();
return R.success(dtos);
}
/**
* 级联选择
*
* @return
*/
@PostMapping("/product/cascade")
public R findProductCascade(){
public R findProductCascade() {
List<CascadeVo> dtos = qinCeProductQueryService.findProductCascade();
return R.success(dtos);
}
/**
* 根据69码选择商品
*/
@GetMapping("/product/info")
public R findProductInfo(QinceProductInfoDto params) {
if (StringUtils.isBlank(params.getPrdSpec())) {
throw new ParamException(RCode.BAR_CODE_IS_ERROR, null);
}
QinceProductInfoDto productInfo = qinCeProductQueryService.findProductInfo(params);
if (Objects.isNull(productInfo)) {
throw new ParamException(RCode.BAR_CODE_IS_ERROR, null);
}
return R.success(productInfo);
}
}
......@@ -71,25 +71,54 @@ public class PromotionStoreDaoImpl implements PromotionStoreDao {
@Override
public void qinceShopDetailAllTask(JSONArray responseDatas) {
// for (Object responseData : responseDatas) {
// JSONObject jo = JSONObject.parseObject(JSONObject.toJSONString(responseData));
// try {
// PromotionStoreDO storeDo = new PromotionStoreDO();
// storeDo.setQcId(jo.getString("id"))
// .setStoreName(jo.getString("store_name"))
// .setProvince(jo.getString("store_mss_province"))
// .setCity(jo.getString("store_mss_city"))
// .setArea(jo.getString("store_mss_area"))
// .setStreet(jo.getString("store_mss_street"))
// .setAddress(jo.getString("store_addr"))
// .setTemporaryId(0)
// .setTemporaryName("系统同步");
// promotionStoreMapper.insert(storeDo);
// } catch (Exception e) {
// log.error("勤策-同步终端store数据异常,异常数据:{}", responseData);
// log.error("勤策-同步终端store数据异常\n{}", e.getMessage());
// }
// }
LambdaQueryWrapper<PromotionStoreDO> qw = new LambdaQueryWrapper<>();
for (Object responseData : responseDatas) {
qw.clear();
try {
JSONObject jo = JSONObject.parseObject(JSONObject.toJSONString(responseData));
PromotionStoreDO storeDo = new PromotionStoreDO();
storeDo.setQcId(jo.getString("id"))
.setStoreName(jo.getString("store_name"))
.setProvince(jo.getString("store_mss_province"))
.setCity(jo.getString("store_mss_city"))
.setArea(jo.getString("store_mss_area"))
.setStreet(jo.getString("store_mss_street"))
.setAddress(jo.getString("store_addr"))
.setTemporaryId(0)
.setTemporaryName("系统同步")
.setStoreManager(jo.getString("store_manager"))
.setStoreManagerWaiqin365Id(jo.getString("store_manager_waiqin365_id"));
if (StringUtils.isBlank(storeDo.getQcId())) {
continue;
}
JSONArray dealersJR = jo.getJSONArray("dealers");
if (!CollectionUtils.isEmpty(dealersJR)) {
JSONObject dealersJ = dealersJR.getJSONObject(0);
storeDo.setDealersName(dealersJ.getString("dealer_name"))
.setWaiqin365DealersId(dealersJ.getString("waiqin365_dealer_id"));
}
// 判断qc_id是否存在;存在则修改,不存在则新增
qw.eq(PromotionStoreDO::getQcId, storeDo.getQcId());
PromotionStoreDO doExist = promotionStoreMapper.selectOne(qw);
if (Objects.isNull(doExist)) {
promotionStoreMapper.insert(storeDo);
} else {
storeDo.setId(doExist.getId());
promotionStoreMapper.updateById(storeDo);
}
} catch (Exception e) {
log.error("勤策-同步终端到促销店铺数据异常,异常数据:{}", responseData);
log.error("勤策-同步终端到促销店铺数据异常\n{}", e.getMessage());
}
}
}
@Override
......
......@@ -108,6 +108,26 @@ public class PromotionStoreDO implements Serializable {
*/
private String chargerName;
/**
* 门店经理
*/
private String storeManager;
/**
* 门店经理勤策id
*/
private String storeManagerWaiqin365Id;
/**
* 经销商名称
*/
private String dealersName;
/**
* 经销商勤策id
*/
private String waiqin365DealersId;
/**
* 创建时间
*/
......
......@@ -14,7 +14,7 @@ import java.util.List;
public interface QinCeClienteleStoreDao {
/**
* 勤策人员数据同步
* 勤策终端数据同步
*/
void shopDetailAllTask(JSONArray responseDatas);
......
......@@ -15,4 +15,5 @@ public interface QinceProductInfoDao {
List<QinceProductInfoDto> selectList();
QinceProductInfoDto selectOne(QinceProductInfoDto params);
}
......@@ -45,6 +45,14 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
try {
QinCeClienteleStoreDO qinCeShopDO = JSONObject.parseObject(responseData.toString(), QinCeClienteleStoreDO.class);
// 添加经销商
List<JSONObject> dealers = qinCeShopDO.getDealers();
if (!CollectionUtils.isEmpty(dealers)){
qinCeShopDO.setDealersName(dealers.get(0).getString("dealer_name"));
qinCeShopDO.setWaiqin365DealersId(dealers.get(0).getString("waiqin365_dealer_id"));
}
qw.eq(QinCeClienteleStoreDO::getQcId, qinCeShopDO.getQcId());
QinCeClienteleStoreDO doExist = qinCeClienteleStoreMapper.selectOne(qw);
......@@ -58,7 +66,6 @@ public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
log.error("勤策-同步终端store数据异常,异常数据:{}", responseData);
log.error("勤策-同步终端store数据异常\n{}", e.getMessage());
}
}
......
......@@ -9,6 +9,7 @@ import com.wangxiaolu.promotion.domain.user.mapper.entity.QinceProductInfoDO;
import com.wangxiaolu.promotion.pojo.user.dto.QinceProductInfoDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -59,14 +60,30 @@ public class QinceProductInfoDaoImpl implements QinceProductInfoDao {
@Override
public List<QinceProductInfoDto> selectList() {
LambdaQueryWrapper<QinceProductInfoDO> qw = new LambdaQueryWrapper<>();
qw.eq(QinceProductInfoDO::getSaleStatus,1).eq(QinceProductInfoDO::getStatus,1).ne(QinceProductInfoDO::getClassName,"")
.select(QinceProductInfoDO::getClassId,QinceProductInfoDO::getClassName,QinceProductInfoDO::getPrdId,QinceProductInfoDO::getPrdName);
LambdaQueryWrapper<QinceProductInfoDO> qw = buildWrapper(new QinceProductInfoDto());
List<QinceProductInfoDO> qinceProductInfoDOS = qinceProductInfoMapper.selectList(qw);
return transitionDtos(qinceProductInfoDOS);
}
@Override
public QinceProductInfoDto selectOne(QinceProductInfoDto params) {
LambdaQueryWrapper<QinceProductInfoDO> qw = buildWrapper(params);
QinceProductInfoDO qinceProductInfoDO = qinceProductInfoMapper.selectOne(qw);
return transitionDto(qinceProductInfoDO);
}
private LambdaQueryWrapper<QinceProductInfoDO> buildWrapper(QinceProductInfoDto params) {
LambdaQueryWrapper<QinceProductInfoDO> qw = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(params.getPrdSpec())) {
qw.eq(QinceProductInfoDO::getPrdSpec, "条码" + params.getPrdSpec());
}
qw.eq(QinceProductInfoDO::getSaleStatus, 1).eq(QinceProductInfoDO::getStatus, 1).ne(QinceProductInfoDO::getClassName, "");
qw.select(QinceProductInfoDO::getClassId, QinceProductInfoDO::getClassName, QinceProductInfoDO::getPrdId, QinceProductInfoDO::getPrdName);
return qw;
}
/**
* DO to DTO (单个对象)
*
......
......@@ -37,7 +37,7 @@ public class QinceProductTypeDaoImpl implements QinceProductTypeDao {
for (Object responseData : responseDatas) {
qw.clear();
// 查询人员是否存在
// 查询商品是否存在
QinceProductTypeDO qcDo = JSONObject.parseObject(JSONObject.toJSONString(responseData), QinceProductTypeDO.class);
qw.eq(QinceProductTypeDO::getPrdWaiqin365Id, qcDo.getPrdWaiqin365Id());
QinceProductTypeDO doExist = qinceProductTypeMapper.selectOne(qw);
......
package com.wangxiaolu.promotion.domain.user.mapper.entity;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
......@@ -503,6 +505,20 @@ public class QinCeClienteleStoreDO implements Serializable {
@JsonProperty("store_approval_status")
private String storeApprovalStatus;
/**
* 经销商名称
*/
private String dealersName;
/**
* 经销商勤策id
*/
private String waiqin365DealersId;
@TableField(exist = false)
@JsonProperty("dealers")
private List<JSONObject> dealers;
/**
* 门店删除状态。0:删除,1:正常
*/
......
package com.wangxiaolu.promotion.service.user;
import com.wangxiaolu.promotion.pojo.CascadeVo;
import com.wangxiaolu.promotion.pojo.user.dto.QinceProductInfoDto;
import com.wangxiaolu.promotion.pojo.user.dto.QinceProductTypeDto;
import java.util.List;
......@@ -15,5 +16,6 @@ public interface QinCeProductQueryService {
List<CascadeVo> findProductCascade();
QinceProductInfoDto findProductInfo(QinceProductInfoDto params);
}
......@@ -83,6 +83,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
while (nextPage) {
i++;
nextPage = booleanshopDetailPage(i);
nextPage = false;
}
}
......@@ -121,7 +122,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
}
log.info("勤策-同步终端store数据,查询到第{}页数据「{}」条", pageNum, responseDatas.size());
// qinCeClienteleShopDao.shopDetailAllTask(responseDatas);
qinCeClienteleShopDao.shopDetailAllTask(responseDatas);
promotionStoreDao.qinceShopDetailAllTask(responseDatas);
return true;
}
......
......@@ -60,4 +60,9 @@ public class QinCeProductQueryServiceImpl implements QinCeProductQueryService {
return cascades;
}
@Override
public QinceProductInfoDto findProductInfo(QinceProductInfoDto params) {
return qinceProductInfoDao.selectOne(params);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论