Commit 406d05fb by 姜海波

更新最新master代码

parent 9c8277c8
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: PaySuccessTimeoutEnum
* @Package com.freemud.sdk.api.assortment.order.enums
* @Description:
* @author: ping.wu
* @date: 2019/11/8 18:39
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package com.freemud.sdk.api.assortment.order.enums;
public enum PaySuccessTimeoutEnum {
Timeout_1("1", 0),
Timeout_2("2", 1),
Timeout_3("3", 5);
//超时类型
private String code;
//对应的分钟
private Integer min;
PaySuccessTimeoutEnum(String code, Integer min) {
this.code = code;
this.min = min;
}
public static Integer getMin(String code) {
if (code == null) {
return 0;
}
for (PaySuccessTimeoutEnum timeoutEnum : values()) {
if (timeoutEnum.getCode().equals(code)) {
return timeoutEnum.getMin();
}
}
return null;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getMin() {
return min;
}
public void setMin(Integer min) {
this.min = min;
}
}
package com.freemud.sdk.api.assortment.order.util;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
/**
* @author haibo.jiang
* @Description:
* @date 2019/11/6 14:38
*/
public class LockUtils {
private static String redis_lock_after="saas:lockAfter:";
public static Boolean lockAfter(RedisTemplate redisTemplate,String afterId){
return lock(redisTemplate,redis_lock_after+afterId);
}
private static boolean lock(RedisTemplate redisTemplate,String key){
String lock = key;
// 利用lambda表达式
return (Boolean) redisTemplate.execute((RedisCallback) connection -> {
long expireAt = 300;
Boolean acquire = connection.setNX(lock.getBytes(), String.valueOf(expireAt).getBytes());
if (acquire) {
connection.expire(lock.getBytes(),expireAt);
return true;
} else {
return false;
}
});
}
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: OrderExtInfoDto
* @Package cn.freemud.entities.dto
* @Description:
* @author: liming.guo
* @date: 2018/6/13 18:38
* @version V1.0
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto;
import lombok.Data;
@Data
public class OrderExtInfoDto {
private String prepayId;
private String accessToken;
/**
* 到期时间
*/
private String expireDate;
/**
* 外卖开始时间
*/
private String deliveryHoursDayStart;
/**
* 外卖结束时间
*/
private String deliveryHoursDayEnd;
private String openid;
private String appid;
private String appsecret;
/**
* 订单支付时间
*/
private String payDate;
/**
* 第三方流水号
*/
private String payTransId;
/**
* sessionId
*/
private String sessionId;
/**
* 预计送达时间
*/
private Integer serviceTime;
/**
* 第三方外卖定时推单时间
*/
private Integer pushOrderTime;
/**
* 版本号
*/
private String version;
/**
* 会员规则ID
*/
private String ruleId;
/**
* 预支付 transId
*/
private String prePayTransId;
/**
* 预支付返回的fmId
*/
private String fmId;
/**
* 创建预支付订单userId
*/
private String prePayUserId;
/**
* 用户手机号
*/
private String phone;
/**
* 平台支付订单号(微信订单号)
*/
private String paid_no;
/**
* 渠道方流水号 (比如扫呗,易宝等) 新支付服务做中转使用
*/
private String endTransId;
/**
* 第三方支付商户号 新支付服务做中转使用
*/
private String platformMchId;
/**
* 扫呗商户号 新支付服务做中转使用
*/
private String terminalId;
}
package cn.freemud.entities.dto;
import lombok.Data;
@Data
public class UserLoginInfoDto {
private String openId;
private String wxAppid;
private String sessionKey;
private String mobile;
private String appsecret;
private String memberId;
private String partnerId;
private boolean newMemeber;
private String unionId;
private String nickName;
}
package cn.freemud.entities.dto;
import lombok.Data;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.6.0
* @Title: SyncStatusDto
* @Package cn.freemud.entities.dto
* @Description: 简单描述下这个类是做什么用的
* @author: hang.chai
* @date: 2019/3/12 15:00
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class WechatReportOrderDto {
private String partnerId;
/**
* 非码流水Id
*/
private String payVoucher;
/**
* 子商户号
*/
private String sub_mchid;
/**
* 子商户APPID,非必填
*/
private String sub_appid;
/**
* 门店编号
*/
private String out_shop_no;
/**
* 用户子标识 ,非必填
*/
private String sub_openid;
/**
* 登录票据(微信用户登录接口返回的登 录票据 公众号,填写access_token; 小程序,填写session_key;)
*/
private String login_token;
/**
* 总价,单位为分
*/
private int total_amount;
/**
* 优惠金额,单位为分
*/
private int discount_amount;
/**
* 实际支付,单位为分
*/
private int user_amount;
/**
* 订单状态 (CREATE_DEAL—用户下单;PAY_SUCCESS—支付完成)
*/
private String status;
/**
* 微信支付订单号(status 为 PAY_SUCCESS时必填)
*/
private String transaction_id;
/**
* 服务商支付订单号(status为PAY_SUCCESS时 必填)
*/
private String out_trade_no;
/**
* 服务商订单号
*/
private String out_order_no;
/**
* 菜品列表
*/
private List<DishInfo> dish_list;
/**
* 消费人数
*/
private int people_count;
@Data
public static class DishInfo{
/**
* 商户菜品ID
*/
private String out_dish_no;
/**
* 菜品名称
*/
private String name;
/**
* 菜品单价,单位为分
*/
private int price;
/**
* 菜品数量
*/
private float count;
}
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductComboListDto
* @Package cn.freemud.entities.dto
* @Description:
* @author: ping.wu
* @date: 2019/11/26 11:48
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto;
import cn.freemud.entities.dto.product.ProductAttributeGroup;
import lombok.Data;
import java.util.List;
@Data
public class ProductComboListDto {
private String barcode;
private String category;
private String categoryName;
private String customerCode;
private Integer finalPrice;
private String options;
private Integer originalPrice;
private Integer packPrice;
private String picture;
private String productCode;
private String productId;
private String productName;
private Integer productType;
private Integer quantity;
private Integer sequence;
private String specification;
private Integer status;
private Integer stockLimit;
private String unit;
protected List<ProductAttributeGroup> productAttributeGroupList;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: AttributeValue
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:18
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
@Data
public class AttributeValue {
/**
* attributeValue :
* id : 0
* price : 0
* sequence : 0
* status : 0
*/
/**
* 属性值
*/
private String attributeId;
private String attributeValue;
/**
* 属性ID
*/
private Long id;
/**
*
*/
private Long price;
private Integer sequence;
private Integer status;
/**
* 第三方商品属性值编号
*/
private String customerCode;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: GroupDetail
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:27
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class GroupDetail {
private String groupId;
private Long productFinalPrice;
private String productId;
private String productName;
private Long productPrice;
private Integer sequence;
private Integer status;
private Integer stock;
private Integer stockLimit;
private String statusDesc;
private String customerCode;
private String productCode;
protected List<ProductAttributeGroup> productAttributeGroupList;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductAttributeGroup
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:17
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class ProductAttributeGroup {
/**
* attributeName : 加料
* attributeType : 1
* attributeValues : [{"attributeValue":"","id":0,"price":0,"sequence":0,"status":0}]
*/
/**
* 属性名称
*/
private String attributeName;
/**
* 属性类型
*/
private Integer attributeType;
/**
* 第三方商品属性编号
*/
private String customerCode;
/**
* 属性详细信息
*/
private List<AttributeValue> attributeValues;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductGroup
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:26
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class ProductGroup {
private String name;
private List<GroupDetail> groupDetail;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductInfo
* @Package cn.freemud.entities.dto
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:13
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import cn.freemud.entities.dto.ProductComboListDto;
import cn.freemud.entities.dto.ProductGroupDto;
import lombok.Data;
import java.util.List;
@Data
public class ProductInfo {
private String barcode;
private String brandId;
private String brandName;
private String category;
private String categoryName;
private String companyId;
private String customerCode;
/**
* 最终价格 单位分
*/
private Long finalPrice;
/**
* 是否是SKU商品 1是0否
*/
private Integer isSkuProduct;
private String name;
/**
* 原始价格 单位分
*/
private Long originalPrice;
/**
* 包装费 单位分
*/
private Long packPrice;
private String picture;
private String pid;
private Integer pknumber;
private String productionLocation;
private String remark;
private Integer saleCount;
private String sellTimeName;
private Integer sequence;
private String sourceChannel;
private String specification;
private String productCode;
private Integer status;
private Integer stock;
private Integer stockLimit;
/**
* type=10 多规格 type=1 单规格
*/
private int type;
private String unit;
private int updateStatus;
private boolean valid;
private int version;
private List<ProductLabel> labelNames;
private List<ProductAttributeGroup> productAttributeGroupList;
private List<ProductGroup> productGroupList;
private List<ProductComboListDto> productComboList;
private List<ProductPicture> productPictureList;
private List<?> productSpecification;
private List<?> sellTimeList;
private List<?> specificationList;
//SKU
private List<SkuProduct> skuList;
//规格信息
private List<SpecificationGroup> specificationGroupList;
//Sku 规格 如果 当前是sku 则有值
private List<SkuSpecValue> skuSpecValues;
// @NoArgsConstructor
// @Data
// public static class SkuProductBean {
// private String customerCode;
// private String productCode;
// private Long finalPrice;
// private Long originalPrice;
// private String productName;
// private Integer productType;
// private Integer sequence;
// private String skuCode;
// private String skuId;
//
// private Integer status;
// //以下两个字段 1.5.4新加
// private Integer stockLimit;
// private Integer stockQty;
// //sku商品包装费 1.5.4新加
// private Long packPrice ;
// private List<SkuSpecValue> skuSpecValues;
//
// @NoArgsConstructor
// @Data
// public static class SkuSpecValue {
// private String productId;
// private Integer sequence;
// private String specCustomerCode;
// private String specId;
// private String specName;
// private String specValue;
// private String specValueCustomerCode;
// private String specValueId;
// }
// }
//
// @NoArgsConstructor
// @Data
// public static class SpecificationGroupBean {
// private String partnerId;
// private Integer sequence;
// private String specId;
// private String specName;
// private List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.SpecificationGroupBean.SpecValueVo> specValueVos;
//
// @NoArgsConstructor
// @Data
// public static class SpecValueVo {
// private Integer sequence;
// private String specId;
// private String specValue;
// private String specValueId;
// }
// }
//
// @NoArgsConstructor
// @Data
// public static class ProductLabelNameListBean {
// private String id;
// private String name;
// private String partnerId;
// List<?> productList;
// private String storeId;
// private String type;
// }
//
// @NoArgsConstructor
// @Data
// public static class ProductAttributeGroupListBean {
// /**
// * attributeName : 加料
// * attributeType : 1
// * attributeValues : [{"attributeValue":"","id":0,"price":0,"sequence":0,"status":0}]
// */
//
// /**
// * 属性名称
// */
// private String attributeName;
// /**
// * 属性类型
// */
// private Integer attributeType;
// /**
// * 第三方商品属性编号
// */
// private String customerCode;
// /**
// * 属性详细信息
// */
// private List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.ProductAttributeGroupListBean.AttributeValueBean> attributeValues;
//
// @NoArgsConstructor
// @Data
// public static class AttributeValueBean {
// /**
// * attributeValue :
// * id : 0
// * price : 0
// * sequence : 0
// * status : 0
// */
// /**
// * 属性值
// */
// private String attributeId;
//
// private String attributeValue;
// /**
// * 属性ID
// */
// private Long id;
// /**
// *
// */
// private Long price;
// private Integer sequence;
// private Integer status;
// /**
// * 第三方商品属性值编号
// */
// private String customerCode;
// }
// }
//
// @NoArgsConstructor
// @Data
// public static class ProductPictureListBean {
// /**
// * pictureId : 107901339444445753
// * productId : 107901318808470072
// * sequence : 0
// * type : default
// * url : http://ojcpa0rpt.bkt.clouddn.com/xianfengfruit_DishPool_default_30b5f0ca-399a-4be3-9063-12a3d2622a38_1513952518.jpg
// */
//
// private String pictureId;
// private String productId;
// private String sequence;
// private String type;
// private String url;
// }
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductLabel
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:16
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class ProductLabel {
private String id;
private String name;
private String partnerId;
List<?> productList;
private String storeId;
private String type;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: ProductPicture
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:19
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
@Data
public class ProductPicture {
/**
* pictureId : 107901339444445753
* productId : 107901318808470072
* sequence : 0
* type : default
* url : http://ojcpa0rpt.bkt.clouddn.com/xianfengfruit_DishPool_default_30b5f0ca-399a-4be3-9063-12a3d2622a38_1513952518.jpg
*/
private String pictureId;
private String productId;
private String sequence;
private String type;
private String url;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: SkuProduct
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:20
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class SkuProduct {
private String customerCode;
private String productCode;
private Long finalPrice;
private Long originalPrice;
private String productName;
private Integer productType;
private Integer sequence;
private String skuCode;
private String skuId;
private Integer status;
//以下两个字段 1.5.4新加
private Integer stockLimit;
private Integer stockQty;
//sku商品包装费 1.5.4新加
private Long packPrice ;
private List<SkuSpecValue> skuSpecValues;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: SkuSpecValue
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:21
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
@Data
public class SkuSpecValue {
private String productId;
private Integer sequence;
private String specCustomerCode;
private String specId;
private String specName;
private String specValue;
private String specValueCustomerCode;
private String specValueId;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: SpecValueVo
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:22
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
@Data
public class SpecValueVo {
private Integer sequence;
private String specId;
private String specValue;
private String specValueId;
}
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: SpecificationGroup
* @Package cn.freemud.entities.dto.product
* @Description:
* @author: ping.wu
* @date: 2019/11/26 13:22
* @version V1.0
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
package cn.freemud.entities.dto.product;
import lombok.Data;
import java.util.List;
@Data
public class SpecificationGroup {
private String partnerId;
private Integer sequence;
private String specId;
private String specName;
private List<SpecValueVo> specValueVos;
}
package cn.freemud.entities.dto.wechat;
import lombok.Data;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.6.0
* @Title: SyncStatusDto
* @Package cn.freemud.entities.dto
* @Description: 简单描述下这个类是做什么用的
* @author: hang.chai
* @date: 2019/3/12 15:00
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class WechatReportOrderDto {
/**
* 子商户号
*/
private String sub_mchid;
/**
* 子商户APPID,非必填
*/
private String sub_appid;
/**
* 门店编号
*/
private String out_shop_no;
/**
* 用户子标识 ,非必填
*/
private String sub_openid;
/**
* 登录票据(微信用户登录接口返回的登 录票据 公众号,填写access_token; 小程序,填写session_key;)
*/
private String login_token;
/**
* 总价,单位为分
*/
private int total_amount;
/**
* 优惠金额,单位为分
*/
private int discount_amount;
/**
* 微信支付订单号(status 为 PAY_SUCCESS时必填)
*/
private String transaction_id;
/**
* 服务商支付订单号(status为PAY_SUCCESS时 必填)
*/
private String out_trade_no;
/**
* 服务商订单号
*/
private String out_order_no;
/**
* 菜品列表
*/
private List<DishInfo> dish_list;
/**
* 消费人数
*/
private int people_count;
@Data
public static class DishInfo{
/**
* 商户菜品ID
*/
private String out_dish_no;
/**
* 菜品名称
*/
private String name;
/**
* 菜品单价,单位为分
*/
private int price;
/**
* 菜品数量
*/
private float count;
}
}
package cn.freemud.annotations;
import cn.freemud.enums.OrderReportEnum;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface OrderReportType {
OrderReportEnum value();
}
package cn.freemud.config;
import cn.freemud.annotations.OrderReportType;
import cn.freemud.enums.OrderReportEnum;
import cn.freemud.service.SynchronizedOrderService;
import cn.freemud.util.SpringBeanUtil;
import com.google.common.collect.Maps;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;
import java.util.Map;
@Component
@DependsOn("springBeanUtil")
public class OrderReportFactory {
private static Map<OrderReportEnum, SynchronizedOrderService> userRelatedMap = Maps.newConcurrentMap();
public OrderReportFactory(){
ApplicationContext context = SpringBeanUtil.getContext();
Map<String, Object> beanMap = context.getBeansWithAnnotation(OrderReportType.class);
for(Object categoryService : beanMap.values()) {
OrderReportType annotation = categoryService.getClass().getAnnotation(OrderReportType.class);
userRelatedMap.put(annotation.value(), (SynchronizedOrderService)categoryService);
}
}
public static SynchronizedOrderService getSynchronizedOrderService(OrderReportEnum orderReportEnum) {
return userRelatedMap.get(orderReportEnum);
}
}
package cn.freemud.enums;
public enum OrderReportEnum {
/**
*
*/
WECHAT("wechatReport", "微信上报"),
/**
* 限时折扣
*/
SAOBEI("saobeiReport", "扫呗上报"),
;
private String reportTypeCode;
/**
* 上报类型描述
*/
private String desc;
OrderReportEnum(String reportTypeCode, String desc) {
this.reportTypeCode = reportTypeCode;
this.desc = desc;
}
public String getReportTypeCode() {
return reportTypeCode;
}
public void setReportTypeCode(String reportTypeCode) {
this.reportTypeCode = reportTypeCode;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package cn.freemud.order.mapper;
import cn.freemud.order.entity.OpenPlatformPartner;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
import java.util.List;
@Repository
public interface OpenPlatformPartnerDao extends Mapper<OpenPlatformPartner>, MySqlMapper<OpenPlatformPartner> {
List<OpenPlatformPartner> selectOpenPlatformPartnerList(@Param("partnerIdList") List partnerIdList);
List<OpenPlatformPartner> selectOpenPlatformPartner(@Param("partnerId") String partnerId);
}
\ No newline at end of file
package cn.freemud.order.mapper;
import cn.freemud.order.entity.OpenPlatformPartnerPaymentAuth;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
@Repository
public interface OpenPlatformPartnerPaymentAuthDao extends Mapper<OpenPlatformPartnerPaymentAuth>, MySqlMapper<OpenPlatformPartnerPaymentAuth> {
}
\ No newline at end of file
package cn.freemud.order.mapper;
import cn.freemud.order.entity.OpenPlatformPartnerPaymentConfig;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
@Repository
public interface OpenPlatformPartnerPaymentConfigDao extends Mapper<OpenPlatformPartnerPaymentConfig>, MySqlMapper<OpenPlatformPartnerPaymentConfig> {
}
\ No newline at end of file
package cn.freemud.order.mapper;
import cn.freemud.order.entity.OpenPlatformPartnerReportDetail;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;
import java.util.List;
@Repository
public interface OpenPlatformPartnerReportDetailDao extends Mapper<OpenPlatformPartnerReportDetail>, MySqlMapper<OpenPlatformPartnerReportDetail> {
List<OpenPlatformPartnerReportDetail> selectPartnerReportDetails(@Param("partnerId") String partnerId,
@Param("brandName") String brandName,
@Param("storeName") String storeName,
@Param("reportType") Byte reportType,
@Param("status") Byte status,
@Param("orderId") String orderId,
@Param("dealNo") String dealNo,
@Param("thirdDealNo") String thirdDealNo,
@Param("startTime") String startTime,
@Param("endTime") String endTime);
}
\ No newline at end of file
package cn.freemud.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringBeanUtil implements ApplicationContextAware {
private static ApplicationContext context;
public static <T> T getBean(Class<T> clazz) {
return context.getBean(clazz);
}
public static Object getBean(String beanName) {
return context.getBean(beanName);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (context == null) {
context = applicationContext;
}
}
public static ApplicationContext getContext() {
return context;
}
public static String getActiveProfile() {
return context.getEnvironment().getActiveProfiles()[0];
}
}
<?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.freemud.order.mapper.OpenPlatformPartnerDao">
<resultMap id="BaseResultMap" type="cn.freemud.order.entity.OpenPlatformPartner">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="open_appid" jdbcType="VARCHAR" property="openAppid" />
<result column="partner_name" jdbcType="VARCHAR" property="partnerName" />
<result column="subject_name" jdbcType="VARCHAR" property="subjectName" />
<result column="partner_logo" jdbcType="VARCHAR" property="partnerLogo" />
<result column="company_name" jdbcType="VARCHAR" property="companyName" />
<result column="create_name" jdbcType="VARCHAR" property="createName" />
<result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
</resultMap>
<sql id="all_column">
id,
partner_id,
status,
open_appid,
partner_name,
subject_name,
partner_logo,
company_name,
create_name,
gmt_created,
gmt_modified
</sql>
<select id="selectOpenPlatformPartnerList" resultMap="BaseResultMap">
SELECT
<include refid="all_column"/>
FROM open_platform_partner
WHERE 1=1
<if test="partnerIdList.size >0">
AND partner_id IN
<foreach collection="partnerIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
AND status =1
</select>
<select id="selectOpenPlatformPartner" resultMap="BaseResultMap">
SELECT
<include refid="all_column"/>
FROM open_platform_partner
WHERE partner_id = #{partnerId}
order by gmt_created DESC
</select>
</mapper>
\ No newline at end of file
<?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.freemud.order.mapper.OpenPlatformPartnerPaymentAuthDao">
<resultMap id="BaseResultMap" type="cn.freemud.order.entity.OpenPlatformPartnerPaymentAuth">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="pay_code" jdbcType="VARCHAR" property="payCode" />
<result column="sp_mchid" jdbcType="VARCHAR" property="spMtchid" />
<result column="sp_appid" jdbcType="VARCHAR" property="spAppid" />
<result column="serial_no" jdbcType="VARCHAR" property="serialNo" />
<result column="private_key" jdbcType="VARCHAR" property="privateKey" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
</resultMap>
</mapper>
\ No newline at end of file
<?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.freemud.order.mapper.OpenPlatformPartnerPaymentConfigDao">
<resultMap id="BaseResultMap" type="cn.freemud.order.entity.OpenPlatformPartnerPaymentConfig" >
<id column="id" jdbcType="BIGINT" property="id" />
<result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
<result column="sub_mchid" jdbcType="VARCHAR" property="subMchid" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="report_type" jdbcType="TINYINT" property="reportType" />
<result column="auth_id" jdbcType="BIGINT" property="authId" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" />
<result column="gmt_updated" jdbcType="TIMESTAMP" property="gmtModified" />
</resultMap>
</mapper>
\ No newline at end of file
<?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.freemud.order.mapper.OpenPlatformPartnerReportDetailDao">
<resultMap id="BaseResultMap" type="cn.freemud.order.entity.OpenPlatformPartnerReportDetail" >
<id column="id" jdbcType="BIGINT" property="id" />
<result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
<result column="brand_name" jdbcType="VARCHAR" property="brandName" />
<result column="store_id" jdbcType="VARCHAR" property="storeId" />
<result column="store_name" jdbcType="VARCHAR" property="storeName" />
<result column="report_type" jdbcType="TINYINT" property="reportType" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="deal_no" jdbcType="VARCHAR" property="dealNo" />
<result column="third_deal_no" jdbcType="VARCHAR" property="thirdDealNo" />
<result column="wx_order_id" jdbcType="VARCHAR" property="wxOrderId" />
<result column="pay_amount" jdbcType="INT" property="payAmount" />
<result column="sub_mchid" jdbcType="VARCHAR" property="subMchid" />
<result column="sub_appid" jdbcType="VARCHAR" property="subAppid" />
<result column="gmt_created" jdbcType="TIMESTAMP" property="gmtCreated" />
<result column="gmt_updated" jdbcType="TIMESTAMP" property="gmtModified" />
</resultMap>
<select id="selectPartnerReportDetails" resultMap="BaseResultMap">
select * from open_platform_parntner_report_detail where partner_id = #{partnerId}
<if test="brandName != null">
and brand_name = #{brandName}
</if>
<if test="storeName != null">
and store_name = #{storeName}
</if>
<if test="orderId != null">
and order_id = #{orderId}
</if>
<if test="startTime != null">
and gmt_created > #{startTime}
</if>
<if test="endTime != null">
and #{endTime} > gmt_created
</if>
<if test="reportType != null">
and report_type = #{reportType}
</if>
<if test="status != null">
and status = #{status}
</if>
</select>
</mapper>
\ No newline at end of file
package cn.freemud.entities.dto;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-20
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@Data
public class ProductBaseResponse<T> {
private Integer errcode;
private String errmsg;
private T data;
}
package cn.freemud.entities.dto;
import lombok.Builder;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-20
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@Data
@Builder
public class RequiredProductRequest {
private String channel;
private String partnerId;
private String shopId;
}
package cn.freemud.service;
import cn.freemud.entities.vo.CartGoods;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-20
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
public interface ProductService {
/**
* 验证购物车里面是否有必须商品
*
* @param partnerId
* @param storeId
* @param cartGoodsList
* @return
*/
boolean hasRequiredProducts(String partnerId, String storeId, List<CartGoods> cartGoodsList);
}
package cn.freemud.service.impl;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.ProductBaseResponse;
import cn.freemud.entities.dto.RequiredProductRequest;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.service.ProductService;
import cn.freemud.service.thirdparty.ProductClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-20
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@Service
public class ProductServiceImpl implements ProductService {
@Autowired
private ProductClient productClient;
@Override
public boolean hasRequiredProducts(String partnerId, String storeId, List<CartGoods> cartGoodsList) {
RequiredProductRequest request = RequiredProductRequest.builder().channel("saas").partnerId(partnerId).shopId(storeId).build();
ProductBaseResponse<List<String>> requiredProductList = productClient.getRequiredProductList(request);
if (null != requiredProductList && ResponseCodeConstant.RESPONSE_SUCCESS.equals(requiredProductList.getErrcode()) &&
!CollectionUtils.isEmpty(requiredProductList.getData())) {
List<String> spuIds = cartGoodsList.stream().map(good -> good.getSpuId()).collect(Collectors.toList());
// 两个集合只要没有交集,就返回true
if (CollectionUtils.isEmpty(requiredProductList.getData().stream().filter(item -> spuIds.contains(item)).collect(Collectors.toList()))) {
return true;
}
}
return false;
}
}
package cn.freemud.service.impl;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.IPromotionService;
import com.google.common.collect.Lists;
import lombok.Data;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-14
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@Service("twoNDiscountService")
public class TwoNDiscountServiceImpl implements IPromotionService {
@Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
List<ApportionGoodsDetail> apportionGoodsDetailList = getApportionGoodsDetail(calculationDiscountResult);
if (!CollectionUtils.isEmpty(apportionGoodsDetailList)) {
List<String> goodIdsList = apportionGoodsDetailList.stream().map(ApportionGoodsDetail::getGoodsId).collect(Collectors.toList());
List<CartGoods> list = cartGoodsList.stream().filter(cartGoods -> goodIdsList.contains(cartGoods.getGoodsId())).collect(Collectors.toList());
Map<String, ApportionGoodsDetail> map = apportionGoodsDetailList.stream().collect(Collectors.toMap(ApportionGoodsDetail::getGoodsId, detail -> detail));
Map<String, Long> mapPro = apportionGoodsDetailList.stream().collect(Collectors.toMap(ApportionGoodsDetail::getGoodsId, detail -> detail.getActivityApportionAmount()));
if (!CollectionUtils.isEmpty(list)) {
for (CartGoods cartGoods : list) {
if (mapPro.get(cartGoods.getGoodsId()) > 0) {
cartGoods.setAmount(cartGoods.getAmount() - map.get(cartGoods.getGoodsId()).getActivityApportionAmount());
mapPro.put(cartGoods.getGoodsId(), mapPro.get(cartGoods.getGoodsId()) - map.get(cartGoods.getGoodsId()).getActivityApportionAmount());
}
}
}
}
}
@Override
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
}
private List<ApportionGoodsDetail> getApportionGoodsDetail(ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult) {
// 遍历购物车内的商品,如果存在则进行均摊
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getApportionGoods())) {
return null;
}
List<ApportionGoodsDetail> list = Lists.newArrayList();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods apportionGood : calculationDiscountResult.getApportionGoods()) {
if (!CollectionUtils.isEmpty(apportionGood.getApportionDetails())) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods.ApportionDetails apportionDetail : apportionGood.getApportionDetails()) {
if (apportionDetail.getActivityType().equals(ActivityTypeEnum.TYPE_53.getCode())) {
ApportionGoodsDetail apportionGoodsDetail = new ApportionGoodsDetail();
apportionGoodsDetail.setActivityApportionAmount(apportionDetail.getActivityApportionAmount());
apportionGoodsDetail.setActivityCode(apportionDetail.getActivityCode());
apportionGoodsDetail.setActivityName(apportionDetail.getActivityName());
apportionGoodsDetail.setGoodsId(apportionGood.getGoodsId());
list.add(apportionGoodsDetail);
}
}
}
}
return list;
}
@Data
private class ApportionGoodsDetail {
/**
* 活动code,如果是商品券,优惠券,放券code
*/
private String activityCode;
/**
* 活动名称,如果是商品券,优惠券,放券名称
*/
private String activityName;
/**
* 活动均摊金额
*/
private Long activityApportionAmount;
private String goodsId;
}
}
package cn.freemud.service.thirdparty;
import cn.freemud.entities.dto.ProductBaseResponse;
import cn.freemud.entities.dto.RequiredProductRequest;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: null.java
* @Package
* @Description: (用一句话描述该文件做什么)
* @author: 蓝胖子(Hector)
* @date: 2019-11-20
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
@FeignClient(name = "PRODUCTSERVICE", url = "${saas.storeitemclient.feign.url}")
@RequestMapping(produces = {"application/json;charset=UTF-8"})
public interface ProductClient {
@PostMapping({"/Shop/ListMenuMustProduct"})
ProductBaseResponse<List<String>> getRequiredProductList(@RequestBody RequiredProductRequest request);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment