思迅同步
This commit is contained in:
parent
9649207ec0
commit
48ecde00a5
@ -99,6 +99,21 @@
|
||||
<systemPath>${project.basedir}/lib/core-1.0.3.jar</systemPath>
|
||||
-->
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>2.7.18</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>2.7.18</version>
|
||||
</dependency>
|
||||
|
||||
<!--excel工具-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的商品分类表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "商品分类表", description = "商品分类表")
|
||||
public class SxSyncCategory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String store_id;
|
||||
|
||||
@ApiModelProperty(value = "分类编码")
|
||||
private String item_clsno;
|
||||
|
||||
@ApiModelProperty(value = "分类名称")
|
||||
private String item_clsname;
|
||||
|
||||
@ApiModelProperty(value = "父类编号")
|
||||
private String cls_parent;
|
||||
|
||||
@ApiModelProperty(value = "分类排序")
|
||||
private Integer item_order;
|
||||
|
||||
@ApiModelProperty(value = "是否显示:1-前台显示 0-前台不显示")
|
||||
private Integer display_flag;
|
||||
|
||||
@ApiModelProperty(value = "同步时间戳")
|
||||
private Long sync_time;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的商品表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "商品信息表", description = "商品信息表")
|
||||
public class SxSyncGoods implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String store_id;
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String item_no;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String item_subname;
|
||||
|
||||
@ApiModelProperty(value = "商品条码")
|
||||
private String item_subno;
|
||||
|
||||
@ApiModelProperty(value = "大分类Id")
|
||||
private String big_clsno;
|
||||
|
||||
@ApiModelProperty(value = "大分类名称")
|
||||
private String big_cls_name;
|
||||
|
||||
@ApiModelProperty(value = "小分类名称")
|
||||
private String small_cls_name;
|
||||
|
||||
@ApiModelProperty(value = "规格")
|
||||
private String item_size;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String unit_no;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private BigDecimal stock;
|
||||
|
||||
@ApiModelProperty(value = "毛利率")
|
||||
private BigDecimal gross_margin;
|
||||
|
||||
@ApiModelProperty(value = "进货价")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "零售价")
|
||||
private BigDecimal sale_price;
|
||||
|
||||
@ApiModelProperty(value = "会员价")
|
||||
private BigDecimal vip_price;
|
||||
|
||||
@ApiModelProperty(value = "商品状态")
|
||||
private Integer sale_flag;
|
||||
|
||||
@ApiModelProperty(value = "品牌名称")
|
||||
private BigDecimal item_brand_name;
|
||||
|
||||
@ApiModelProperty(value = "商品助记号")
|
||||
private Integer item_rem;
|
||||
|
||||
@ApiModelProperty(value = "生产日期")
|
||||
private String build_date;
|
||||
|
||||
@ApiModelProperty(value = "质保期")
|
||||
private String valid_days;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的商品表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "商品同步日志表", description = "商品同步日志表")
|
||||
public class SxSyncGoodsLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String item_no;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "同步时间")
|
||||
private Long sync_time;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的促销活动表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "促销活动表", description = "促销活动表")
|
||||
public class SxSyncPlan implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String store_id;
|
||||
|
||||
@ApiModelProperty(value = "促销活动编号")
|
||||
private String plan_no;
|
||||
|
||||
@ApiModelProperty(value = "会员名称")
|
||||
private String plan_name;
|
||||
|
||||
@ApiModelProperty(value = "促销开始日期")
|
||||
private String begin_date;
|
||||
|
||||
@ApiModelProperty(value = "促销结束日期")
|
||||
private String end_date;
|
||||
|
||||
@ApiModelProperty(value = "星期")
|
||||
private String week;
|
||||
|
||||
@ApiModelProperty(value = "是否会员 Y全部会员 N非会员 无 无")
|
||||
private String vip_type;
|
||||
|
||||
@ApiModelProperty(value = "审核标志 1已审核 0未审核")
|
||||
private Integer approve_flag;
|
||||
|
||||
@ApiModelProperty(value = "促销模式 ps特价 DD 打折")
|
||||
private String rule_no;
|
||||
|
||||
@ApiModelProperty(value = "促销类型 1按商品 A按全场 C按类别")
|
||||
private String range_flag;
|
||||
|
||||
@ApiModelProperty(value = "是否启用时间段 1启用 0不启用价")
|
||||
private Integer is_time;
|
||||
|
||||
@ApiModelProperty(value = "开始时间段")
|
||||
private String time_begin;
|
||||
|
||||
@ApiModelProperty(value = "结束时间段")
|
||||
private String time_end;
|
||||
|
||||
@ApiModelProperty(value = "活动门店 ALL所有 其他数值是门店编号")
|
||||
private String oper_branch;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "同步时间")
|
||||
private Long sync_time;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的促销活动表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "促销活动详情表", description = "促销活动详情表")
|
||||
public class SxSyncPlanDetail implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String store_id;
|
||||
|
||||
@ApiModelProperty(value = "促销活动编号")
|
||||
private String plan_no;
|
||||
|
||||
@ApiModelProperty(value = "促销类型 1按商品 A按全场 C按类别")
|
||||
private String range_flag;
|
||||
|
||||
@ApiModelProperty(value = "促销商品货号促销类别")
|
||||
private String item_no;
|
||||
|
||||
@ApiModelProperty(value = "促销价格促销折扣")
|
||||
private BigDecimal value;
|
||||
|
||||
@ApiModelProperty(value = "开始时间段")
|
||||
private String begin_time;
|
||||
|
||||
@ApiModelProperty(value = "结束时间段")
|
||||
private String end_time;
|
||||
|
||||
@ApiModelProperty(value = "限量数量")
|
||||
private Integer limit_qty;
|
||||
|
||||
@ApiModelProperty(value = "审核标志 1已审核 0未审核")
|
||||
private BigDecimal num2;
|
||||
|
||||
@ApiModelProperty(value = "促销模式 ps特价 DD 打折")
|
||||
private BigDecimal num3;
|
||||
|
||||
@ApiModelProperty(value = "同步时间")
|
||||
private Long sync_time;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.sixun;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 思迅同步的商品表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ApiModel(value = "会员表", description = "会员表")
|
||||
public class SxSyncVip implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "自增ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "店铺Id")
|
||||
private String store_id;
|
||||
|
||||
@ApiModelProperty(value = "会员编号")
|
||||
private String vip_no;
|
||||
|
||||
@ApiModelProperty(value = "会员名称")
|
||||
private String vip_name;
|
||||
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty(value = "会员性别")
|
||||
private String vip_sex;
|
||||
|
||||
@ApiModelProperty(value = "会员生日")
|
||||
private String birthday;
|
||||
|
||||
@ApiModelProperty(value = "会员卡号")
|
||||
private String card_no;
|
||||
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
private String card_type;
|
||||
|
||||
@ApiModelProperty(value = "储值余额")
|
||||
private BigDecimal residual_amt;
|
||||
|
||||
@ApiModelProperty(value = "会员积分")
|
||||
private BigDecimal now_acc_num;
|
||||
|
||||
@ApiModelProperty(value = "加入时间")
|
||||
private String vip_date;
|
||||
|
||||
@ApiModelProperty(value = "会员状态")
|
||||
private Integer card_status;
|
||||
|
||||
@ApiModelProperty(value = "同步时间")
|
||||
private Long sync_time;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "新增时间")
|
||||
private Date created_at;
|
||||
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
}
|
||||
@ -227,4 +227,7 @@ public class CommonUtil {
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ public class ShopProductItemController {
|
||||
@RequestParam(name = "comment_flag", required = false) Integer comment_flag,
|
||||
@RequestParam(name = "frontend_id", defaultValue = "5") Integer frontend_id,
|
||||
@RequestParam(name = "currency_id", required = false) Integer currency_id,
|
||||
@RequestParam(name = "district_id", required = false) Integer district_id,
|
||||
@RequestParam(name = "gb_id", required = false) String gb_id) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("item_id", item_id);
|
||||
@ -59,6 +60,7 @@ public class ShopProductItemController {
|
||||
params.put("comment_flag", comment_flag);
|
||||
params.put("frontend_id", frontend_id);
|
||||
params.put("currency_id", currency_id);
|
||||
if(district_id != null) {params.put("district_id", district_id);}
|
||||
params.put("gb_id", gb_id);
|
||||
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
@ -69,6 +69,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -399,7 +400,13 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
data.put("product_freight_info", product_freight_info);
|
||||
} else {
|
||||
// todo 判断是否有配送地区
|
||||
Integer district_id = shopBaseDistrictService.getDefaultDistrictId();
|
||||
Integer district_id;
|
||||
if (params.get("district_id")==null) {
|
||||
district_id = shopBaseDistrictService.getDefaultDistrictId();
|
||||
}else{
|
||||
district_id = Convert.toInt(params.get("district_id"));
|
||||
}
|
||||
|
||||
// todo 状态正常、可配送区域、商品数量
|
||||
Map product_freight_info = shopProductBaseService.getProductFreightInfo(item_row, district_id);
|
||||
data.put("product_freight_info", product_freight_info);
|
||||
@ -627,7 +634,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
// 评价信息
|
||||
boolean evaluation_enable = accountBaseConfigService.getConfig("evaluation_enable", false);
|
||||
Map product_analytics_row = new HashMap<>();
|
||||
if (evaluation_enable || true) {
|
||||
if (true) {
|
||||
product_analytics_row = shopProductAnalyticsService.getAnalytics(product_id);
|
||||
}
|
||||
|
||||
@ -825,7 +832,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
|
||||
for (int k = 0; k < item_spec.size(); k++) {
|
||||
JSONObject json_item_spec = (JSONObject) item_spec.get(k);
|
||||
JSONObject spec_item_tmp_row = (JSONObject) ((JSONObject) json_item_spec).get("item");
|
||||
JSONObject spec_item_tmp_row = (JSONObject) json_item_spec.get("item");
|
||||
Long spec_item_tmp_row_id = Convert.toLong(spec_item_tmp_row.get("id"));
|
||||
if (ObjectUtil.notEqual(i, k)) {
|
||||
spec_item_ids.add(spec_item_tmp_row_id);
|
||||
@ -859,7 +866,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
if (activity_item_opl.isPresent()) {
|
||||
Map activity_item = activity_item_opl.get();
|
||||
Map activity_type_row = Convert.toMap(String.class, Object.class, activity_item.get("activity_type_row"));
|
||||
activity_type_row = (Map) ObjectUtil.defaultIfNull(activity_type_row, new HashMap());
|
||||
activity_type_row = ObjectUtil.defaultIfNull(activity_type_row, new HashMap());
|
||||
|
||||
item_row.put("activity_id", activity_item.get("activity_id"));
|
||||
item_row.put("activity_type_id", activity_item.get("activity_type_id"));
|
||||
@ -891,7 +898,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
int item_quantity = Integer.valueOf(StrUtil.isBlank(item_data.get("item_quantity").toString()) ? 1 : Integer.valueOf(item_data.get("item_quantity").toString()));
|
||||
item_data.put("activity_quantity", item_quantity);
|
||||
BigDecimal item_unit_price = Convert.toBigDecimal(item_data.get("item_unit_price"), BigDecimal.valueOf(0));
|
||||
item_data.put("activity_item_old_price", item_unit_price.multiply(BigDecimal.valueOf(item_quantity)).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
item_data.put("activity_item_old_price", item_unit_price.multiply(BigDecimal.valueOf(item_quantity)).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
activity_item_row.put("reduction_item_data", product_item_data);
|
||||
@ -1000,7 +1007,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
// 是否可以放入购物车
|
||||
item_row.put("if_cart", 1);
|
||||
item_row.put("category_id", product_index_row.get("category_id"));
|
||||
if (evaluation_enable || true) {
|
||||
if (true) {
|
||||
item_row.put("analytics_row", product_analytics_row);
|
||||
} else {
|
||||
item_row.put("analytics_row", new HashMap<>());
|
||||
@ -1310,7 +1317,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
if (null == shopProductImage) {
|
||||
shopProductImage = new ShopProductImage();
|
||||
shopProductImage.setStore_id(store_id);
|
||||
shopProductImage.setColor_id(0l);
|
||||
shopProductImage.setColor_id(0L);
|
||||
}
|
||||
shopProductImage.setItem_image_default(product_image);
|
||||
shopProductImage.setItem_image_other(eduCourseDetailDTO.getItem_image_other());
|
||||
@ -1637,7 +1644,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
*/
|
||||
@Override
|
||||
public Map getCourseData(Long product_id) {
|
||||
List<Map> courseData = handleCourseData(Arrays.asList(eduService.getCourseData(product_id)));
|
||||
List<Map> courseData = handleCourseData(Collections.singletonList(eduService.getCourseData(product_id)));
|
||||
if (CollUtil.isNotEmpty(courseData)) return courseData.get(0);
|
||||
return new HashMap();
|
||||
}
|
||||
@ -1990,7 +1997,7 @@ public class ShopProductItemServiceImpl extends BaseServiceImpl<ShopProductItemM
|
||||
public Map getItem(Long item_id_row) {
|
||||
if (item_id_row == null) return new HashMap();
|
||||
|
||||
List<Long> item_id_rows = Arrays.asList(item_id_row);
|
||||
List<Long> item_id_rows = Collections.singletonList(item_id_row);
|
||||
List<Map> itemList = getItem(item_id_rows);
|
||||
|
||||
return CollUtil.isNotEmpty(itemList) ? itemList.get(0) : new HashMap();
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.controller;
|
||||
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.shop.sixun.service.SxSyncCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Api(tags = "思迅同步商品分类")
|
||||
@RestController
|
||||
@RequestMapping("/admin/sixun/goods/category")
|
||||
public class SxSyncCategoryController {
|
||||
@Resource
|
||||
private SxSyncCategoryService sxSyncCategoryService;
|
||||
|
||||
@ApiOperation(value = "获取思迅商品分类新增到数据库", notes = "获取思迅商品分类新增到数据库")
|
||||
@RequestMapping(value = "/sync", method = RequestMethod.POST)
|
||||
public CommonResult list(@RequestParam(name = "storeId", defaultValue = "1") String storeId,
|
||||
@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(name = "pageSize", defaultValue = "100") Integer pageSize) {
|
||||
|
||||
return sxSyncCategoryService.syncCategory(storeId, pageNum, pageSize);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncCategory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface SxSyncCategoryMapper extends BaseMapper<SxSyncCategory> {
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncCategory;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncVip;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface SxSyncVipMapper extends BaseMapper<SxSyncVip> {
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.service;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SxSyncCategoryService {
|
||||
|
||||
/**
|
||||
* 同步店铺的商品分类
|
||||
*
|
||||
* @param storeId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
CommonResult syncCategory(String storeId, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 新增记录,存在了就不新增
|
||||
*
|
||||
* @param sxSyncCategory
|
||||
* @return
|
||||
*/
|
||||
Integer insert(SxSyncCategory sxSyncCategory);
|
||||
|
||||
/**
|
||||
* 批量更新思迅的商品分类,有判断是否已存在逻辑
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
Integer insertBatch(String storeId, List<SxSyncCategory> list);
|
||||
|
||||
/**
|
||||
* 根据分类编号更新一条记录
|
||||
*
|
||||
* @param sxSyncCategory
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByItemClsNo(SxSyncCategory sxSyncCategory);
|
||||
|
||||
/**
|
||||
* 根据分类编号获取一条记录
|
||||
*
|
||||
* @param storeId
|
||||
* @param itemClsNo
|
||||
* @return
|
||||
*/
|
||||
SxSyncCategory getByItemClsno(String storeId, String itemClsNo);
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.service;
|
||||
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncCategory;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncVip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SxSyncVipService {
|
||||
|
||||
/**
|
||||
* 同步店铺的会员
|
||||
*
|
||||
* @param storeId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
CommonResult syncVip(String storeId, Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 新增记录,存在了就不新增
|
||||
*
|
||||
* @param sxSyncVip
|
||||
* @return
|
||||
*/
|
||||
Integer insert(SxSyncVip sxSyncVip);
|
||||
|
||||
/**
|
||||
* 批量更新思迅的会员,有判断是否已存在逻辑
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
Integer insertBatch(String storeId, List<SxSyncVip> list);
|
||||
|
||||
/**
|
||||
* 根据编号更新一条记录
|
||||
*
|
||||
* @param sxSyncVip
|
||||
* @return
|
||||
*/
|
||||
Boolean updateByVipNo(SxSyncVip sxSyncVip);
|
||||
|
||||
/**
|
||||
* 根据编号获取一条记录
|
||||
*
|
||||
* @param storeId
|
||||
* @param vipNo
|
||||
* @return
|
||||
*/
|
||||
SxSyncVip getByVipNo(String storeId, String vipNo);
|
||||
}
|
||||
@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2024. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncCategory;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.sixun.mapper.SxSyncCategoryMapper;
|
||||
import com.suisung.mall.shop.sixun.service.SxSyncCategoryService;
|
||||
import com.suisung.mall.shop.sixun.utils.CommonUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class SxSyncCategoryServiceImpl extends BaseServiceImpl<SxSyncCategoryMapper, SxSyncCategory> implements SxSyncCategoryService {
|
||||
|
||||
/**
|
||||
* 同步店铺的商品分类
|
||||
*
|
||||
* @param storeId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult syncCategory(String storeId, Integer pageNum, Integer pageSize) {
|
||||
// 记录总数
|
||||
Integer total = getCategoryRecordTotal("", pageNum, pageSize);
|
||||
// 总页数
|
||||
int pages = CommonUtil.getPagesCount(total,pageSize);
|
||||
|
||||
int syncCount = 0;
|
||||
|
||||
for (int i = 0; i < pages; i++) {
|
||||
List<SxSyncCategory> list = pageCategoryListFromSiXun("", pageNum, pageSize);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
syncCount = insertBatch(storeId, list);
|
||||
if (syncCount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
syncCount++;
|
||||
}
|
||||
|
||||
return CommonResult.success(null, syncCount + "条数据同步成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param sxSyncCategory
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer insert(SxSyncCategory sxSyncCategory) {
|
||||
SxSyncCategory existsCategory = getByItemClsno(sxSyncCategory.getStore_id(), sxSyncCategory.getItem_clsno());
|
||||
if (existsCategory != null) {
|
||||
// 置空无关的属性值
|
||||
existsCategory.setId(null);
|
||||
existsCategory.setStatus(null);
|
||||
existsCategory.setSync_time(null);
|
||||
existsCategory.setCreated_at(null);
|
||||
existsCategory.setUpdated_at(null);
|
||||
|
||||
// 比较对象各个字段是否有改变?
|
||||
if (Objects.deepEquals(existsCategory, sxSyncCategory)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return updateByItemClsNo(sxSyncCategory) ? 1 : 0;
|
||||
}
|
||||
|
||||
return baseMapper.insert(sxSyncCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新思迅的商品分类,有判断是否已存在逻辑
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer insertBatch(String storeId, List<SxSyncCategory> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (SxSyncCategory sxSyncCategory : list) {
|
||||
sxSyncCategory.setStore_id(storeId);
|
||||
if (insert(sxSyncCategory) > 0) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类编号更新一条记录
|
||||
*
|
||||
* @param sxSyncCategory
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByItemClsNo(SxSyncCategory sxSyncCategory) {
|
||||
UpdateWrapper<SxSyncCategory> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("item_clsno", sxSyncCategory.getItem_clsno());
|
||||
return update(sxSyncCategory, updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类编号获取一条记录
|
||||
*
|
||||
* @param itemClsNo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SxSyncCategory getByItemClsno(String storeId, String itemClsNo) {
|
||||
QueryWrapper<SxSyncCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
queryWrapper.eq("item_clsno", itemClsNo);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
// ########### 从思迅商锐9.7系统获取数据区域 开始
|
||||
|
||||
public List<SxSyncCategory> pageCategoryListFromSiXun(String clsParent, Integer pageNo, Integer pageSize) {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("clsParent", clsParent);
|
||||
params.put("pageNo", pageNo);
|
||||
params.put("pageSize", pageSize);
|
||||
|
||||
JSONObject respObj = CommonUtil.sendPostRequestToSiXun( "/v1/category/page", params);
|
||||
if (respObj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!respObj.getStr("code").equals("0") || respObj.get("data") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 驼峰命名改成下划线命名
|
||||
String listJson = StrUtil.toUnderlineCase(respObj.getByPath("data.list", String.class));
|
||||
return JSONUtil.toList(listJson, SxSyncCategory.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类的页数
|
||||
*
|
||||
* @param clsParent
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Integer getCategoryRecordTotal(String clsParent, Integer pageNo, Integer pageSize) {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("clsParent", clsParent);
|
||||
params.put("pageNo", pageNo);
|
||||
params.put("pageSize", pageSize);
|
||||
|
||||
JSONObject respObj = CommonUtil.sendPostRequestToSiXun( "/v1/category/page", params);
|
||||
if (respObj == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!respObj.getStr("code").equals("0") || respObj.get("total") == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Convert.toInt(respObj.get("total"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ########### 从思迅商锐9.7系统获取数据区域 结束
|
||||
}
|
||||
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.sixun.SxSyncVip;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.sixun.mapper.SxSyncVipMapper;
|
||||
import com.suisung.mall.shop.sixun.service.SxSyncVipService;
|
||||
import com.suisung.mall.shop.sixun.utils.CommonUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class SxSyncVipServiceImpl extends BaseServiceImpl<SxSyncVipMapper, SxSyncVip> implements SxSyncVipService {
|
||||
|
||||
/**
|
||||
* 同步店铺的会员
|
||||
*
|
||||
* @param storeId
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult syncVip(String storeId, Integer pageNum, Integer pageSize) {
|
||||
// 记录总数
|
||||
Integer total = getVipRecordTotal(pageNum, pageSize);
|
||||
// 总页数
|
||||
int pages = CommonUtil.getPagesCount(total,pageSize);
|
||||
|
||||
int syncCount = 0;
|
||||
|
||||
for (int i = 0; i < pages; i++) {
|
||||
List<SxSyncVip> list = pageVipListFromSiXun(pageNum, pageSize);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
syncCount = insertBatch(storeId, list);
|
||||
if (syncCount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
syncCount++;
|
||||
}
|
||||
|
||||
return CommonResult.success(null, syncCount + "条数据同步成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增记录
|
||||
*
|
||||
* @param sxSyncVip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer insert(SxSyncVip sxSyncVip) {
|
||||
SxSyncVip existsVip = getByVipNo(sxSyncVip.getStore_id(), sxSyncVip.getVip_no());
|
||||
if (existsVip != null) {
|
||||
// 置空无关的属性值
|
||||
existsVip.setId(null);
|
||||
existsVip.setStatus(null);
|
||||
existsVip.setSync_time(null);
|
||||
existsVip.setCreated_at(null);
|
||||
existsVip.setUpdated_at(null);
|
||||
|
||||
// 比较对象各个字段是否有改变?
|
||||
if (Objects.deepEquals(existsVip, sxSyncVip)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return updateByVipNo(sxSyncVip) ? 1 : 0;
|
||||
}
|
||||
|
||||
return baseMapper.insert(sxSyncVip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新思迅的会员,有判断是否已存在逻辑
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Integer insertBatch(String storeId, List<SxSyncVip> list) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (SxSyncVip sxSyncVip : list) {
|
||||
sxSyncVip.setStore_id(storeId);
|
||||
if (insert(sxSyncVip) > 0) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据会员编号更新一条记录
|
||||
*
|
||||
* @param sxSyncVip
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByVipNo(SxSyncVip sxSyncVip) {
|
||||
UpdateWrapper<SxSyncVip> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("vip_no", sxSyncVip.getVip_no());
|
||||
return update(sxSyncVip, updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据会员编号获取一条记录
|
||||
*
|
||||
* @param vipNo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SxSyncVip getByVipNo(String storeId, String vipNo) {
|
||||
QueryWrapper<SxSyncVip> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
queryWrapper.eq("vip_no", vipNo);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
// ########### 从思迅商锐9.7系统获取数据区域 开始
|
||||
|
||||
public List<SxSyncVip> pageVipListFromSiXun( Integer pageNo, Integer pageSize) {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("pageNo", pageNo);
|
||||
params.put("pageSize", pageSize);
|
||||
|
||||
JSONObject respObj = CommonUtil.sendPostRequestToSiXun( "/v1/vip/page", params);
|
||||
if (respObj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!respObj.getStr("code").equals("0") || respObj.get("data") == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 驼峰命名改成下划线命名
|
||||
String listJson = StrUtil.toUnderlineCase(respObj.getByPath("data.list", String.class));
|
||||
return JSONUtil.toList(listJson, SxSyncVip.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员的页数
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public Integer getVipRecordTotal(Integer pageNo, Integer pageSize) {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("pageNo", pageNo);
|
||||
params.put("pageSize", pageSize);
|
||||
|
||||
JSONObject respObj = CommonUtil.sendPostRequestToSiXun( "/v1/vip/page", params);
|
||||
if (respObj == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!respObj.getStr("code").equals("0") || respObj.get("total") == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Convert.toInt(respObj.get("total"));
|
||||
}
|
||||
|
||||
// ########### 从思迅商锐9.7系统获取数据区域 结束
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.sixun.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
public class CommonUtil {
|
||||
|
||||
private final static String apiUrl = "http://4ei8850868ux.vicp.fun";
|
||||
|
||||
public static JSONObject sendPostRequestToSiXun(String urlPath, JSONObject params) {
|
||||
String resp = HttpUtil.post(apiUrl + urlPath, params.toString());
|
||||
if (StrUtil.isBlank(resp)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JSONObject respObj = JSONUtil.parseObj(resp);
|
||||
|
||||
return respObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据总条数和分页大小,求页数
|
||||
*
|
||||
* @param total
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
public static Integer getPagesCount(Integer total, Integer pageSize) {
|
||||
if (total == null || pageSize == null || pageSize <= 0 || total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pagesCount = 0;
|
||||
pagesCount = total / pageSize;
|
||||
|
||||
if (total % pageSize > 0) {
|
||||
// 有余数
|
||||
pagesCount++;
|
||||
} else {
|
||||
if (pagesCount == 0) {
|
||||
pagesCount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return pagesCount;
|
||||
}
|
||||
}
|
||||
@ -83,6 +83,7 @@
|
||||
|
||||
<select id="getNearShop2" resultType="java.util.Map">
|
||||
SELECT
|
||||
b.store_id,
|
||||
b.store_logo,
|
||||
b.store_name,
|
||||
b.store_address,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user