| | |
| | | |
| | | private String statusCd = "0"; |
| | | |
| | | private String remark; |
| | | |
| | | List<CouponPropertyPoolConfigDto> configs; |
| | | |
| | | |
| | |
| | | public void setConfigs(List<CouponPropertyPoolConfigDto> configs) { |
| | | this.configs = configs; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.dto.couponPropertyUser; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | public class CouponQrCodeDto implements Serializable{ |
| | | |
| | | |
| | | public CouponQrCodeDto(String couponId, String qrCode, String remark) { |
| | | this.couponId = couponId; |
| | | this.qrCode = qrCode; |
| | | this.remark = remark; |
| | | } |
| | | |
| | | public CouponQrCodeDto() { |
| | | |
| | | } |
| | | |
| | | private String couponId; |
| | | |
| | | private String qrCode; |
| | | |
| | | private String remark; |
| | | |
| | | public String getCouponId() { |
| | | return couponId; |
| | | } |
| | | |
| | | public void setCouponId(String couponId) { |
| | | this.couponId = couponId; |
| | | } |
| | | |
| | | public String getQrCode() { |
| | | return qrCode; |
| | | } |
| | | |
| | | public void setQrCode(String qrCode) { |
| | | this.qrCode = qrCode; |
| | | } |
| | | |
| | | public String getRemark() { |
| | | return remark; |
| | | } |
| | | |
| | | public void setRemark(String remark) { |
| | | this.remark = remark; |
| | | } |
| | | } |
| | |
| | | package com.java110.intf.scm; |
| | | |
| | | import com.java110.config.feign.FeignConfiguration; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.dto.supplier.SupplierDto; |
| | | import com.java110.po.supplier.SupplierPo; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | |
| | | */ |
| | | @RequestMapping(value = "/querySuppliersCount", method = RequestMethod.POST) |
| | | int querySuppliersCount(@RequestBody SupplierDto supplierDto); |
| | | |
| | | @RequestMapping(value = "/generatorQrcode", method = RequestMethod.POST) |
| | | CouponQrCodeDto generatorQrcode(@RequestBody CouponPropertyUserDto couponPropertyUserDto); |
| | | } |
| New file |
| | |
| | | package com.java110.acct.cmd.couponProperty; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.acct.coupon.ICouponAdapt; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.doc.annotation.*; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.intf.acct.ICouponPropertyUserV1InnerServiceSMO; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.ResponseEntity; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | |
| | | |
| | | |
| | | @Java110CmdDoc(title = "生成核销码", |
| | | description = "供业主端生成优惠券核销码", |
| | | httpMethod = "post", |
| | | url = "http://{ip}:{port}/app/couponProperty.generatorCouponQrcode", |
| | | resource = "acctDoc", |
| | | author = "吴学文", |
| | | serviceCode = "couponProperty.generatorCouponQrcode" |
| | | ) |
| | | |
| | | @Java110ParamsDoc(params = { |
| | | @Java110ParamDoc(name = "couponId", length = 30, remark = "优惠券ID"), |
| | | }) |
| | | |
| | | @Java110ResponseDoc( |
| | | params = { |
| | | @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"), |
| | | @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"), |
| | | @Java110ParamDoc(name = "data", type = "Object", remark = "有效数据"), |
| | | @Java110ParamDoc(parentNodeName = "data", name = "qrCode", type = "String", remark = "二维码信息"), |
| | | @Java110ParamDoc(parentNodeName = "data", name = "remark", type = "String", remark = "优惠券核销说明"), |
| | | } |
| | | ) |
| | | |
| | | @Java110ExampleDoc( |
| | | reqBody = "{'couponId':'123123'}", |
| | | resBody = "{'code':0,'msg':'成功','data':{'qrCode':'123123','remark':'nihao'}}" |
| | | ) |
| | | |
| | | @Java110Cmd(serviceCode = "couponProperty.generatorCouponQrcode") |
| | | public class GeneratorCouponQrcodeCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private ICouponPropertyUserV1InnerServiceSMO couponPropertyUserV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | Assert.hasKeyAndValue(reqJson, "couponId", "未包含优惠券ID"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | |
| | | String userId = context.getReqHeaders().get("user-id"); |
| | | |
| | | //校验优惠券是否存在 |
| | | |
| | | CouponPropertyUserDto couponPropertyUserDto = new CouponPropertyUserDto(); |
| | | couponPropertyUserDto.setCouponId(reqJson.getString("couponId")); |
| | | couponPropertyUserDto.setCouponUserId(userId); |
| | | couponPropertyUserDto.setState(CouponPropertyUserDto.STATE_WAIT); |
| | | |
| | | List<CouponPropertyUserDto> couponPropertyUserDtos = couponPropertyUserV1InnerServiceSMOImpl.queryCouponPropertyUsers(couponPropertyUserDto); |
| | | |
| | | if (couponPropertyUserDtos == null || couponPropertyUserDtos.size() < 1) { |
| | | throw new CmdException("优惠券不存在"); |
| | | } |
| | | |
| | | if (!"Y".equals(couponPropertyUserDtos.get(0).getIsExpire())) { |
| | | throw new CmdException("优惠券已过期"); |
| | | } |
| | | |
| | | |
| | | String toType = couponPropertyUserDtos.get(0).getToType(); |
| | | |
| | | ICouponAdapt couponAdapt = ApplicationContextFactory.getBean(ICouponAdapt.COUPON_PRE+toType,ICouponAdapt.class); |
| | | |
| | | if(couponAdapt == null){ |
| | | throw new CmdException("优惠券不支持生成二维码"); |
| | | } |
| | | |
| | | CouponQrCodeDto couponQrCodeDto = couponAdapt.generatorQrcode(couponPropertyUserDtos.get(0)); |
| | | |
| | | context.setResponseEntity(ResultVo.createResponseEntity(couponQrCodeDto)); |
| | | } |
| | | } |
| | |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.intf.acct.ICouponRuleFeeV1InnerServiceSMO; |
| | | import com.java110.po.couponRuleFee.CouponRuleFeePo; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | /** |
| | | * 类表述:删除 |
| | | * 服务编码:couponRuleFee.deleteCouponRuleFee |
| | |
| | | */ |
| | | @Java110Cmd(serviceCode = "couponRule.deleteCouponRuleFee") |
| | | public class DeleteCouponRuleFeeCmd extends Cmd { |
| | | private static Logger logger = LoggerFactory.getLogger(DeleteCouponRuleFeeCmd.class); |
| | | private static Logger logger = LoggerFactory.getLogger(DeleteCouponRuleFeeCmd.class); |
| | | |
| | | @Autowired |
| | | private ICouponRuleFeeV1InnerServiceSMO couponRuleFeeV1InnerServiceSMOImpl; |
| | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | | Assert.hasKeyAndValue(reqJson, "crfId", "crfId不能为空"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空"); |
| | | |
| | | } |
| | | |
| | |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | |
| | | CouponRuleFeePo couponRuleFeePo = BeanConvertUtil.covertBean(reqJson, CouponRuleFeePo.class); |
| | | CouponRuleFeePo couponRuleFeePo = BeanConvertUtil.covertBean(reqJson, CouponRuleFeePo.class); |
| | | int flag = couponRuleFeeV1InnerServiceSMOImpl.deleteCouponRuleFee(couponRuleFeePo); |
| | | |
| | | if (flag < 1) { |
| New file |
| | |
| | | package com.java110.acct.coupon; |
| | | |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | |
| | | public abstract class AbstractCouponAdapt implements ICouponAdapt{ |
| | | |
| | | |
| | | @Override |
| | | public CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto) { |
| | | return new CouponQrCodeDto(couponPropertyUserDto.getCouponId(),"no data","优惠券不支持生成核销码"); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.acct.coupon; |
| | | |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | |
| | | public interface ICouponAdapt { |
| | | |
| | | public static final String COUPON_PRE= "couponProperty"; |
| | | |
| | | /** |
| | | * 生成 优惠券核销二维码 |
| | | * @param couponPropertyUserDto |
| | | * @return |
| | | */ |
| | | CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto); |
| | | } |
| New file |
| | |
| | | package com.java110.acct.coupon.goods; |
| | | |
| | | import com.java110.acct.coupon.AbstractCouponAdapt; |
| | | import com.java110.acct.coupon.ICouponAdapt; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.couponPropertyPool.CouponPropertyPoolDto; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component(ICouponAdapt.COUPON_PRE + "1011") |
| | | public class GoodsCouponAdapt extends AbstractCouponAdapt { |
| | | |
| | | @Autowired |
| | | private ICouponPropertyPoolV1InnerServiceSMO couponPropertyPoolV1InnerServiceSMOmpl; |
| | | |
| | | @Override |
| | | public CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto) { |
| | | |
| | | //非法调入 |
| | | if (StringUtil.isEmpty(couponPropertyUserDto.getCouponId())) { |
| | | return super.generatorQrcode(couponPropertyUserDto); |
| | | } |
| | | |
| | | CouponPropertyPoolDto couponPropertyPoolDto = new CouponPropertyPoolDto(); |
| | | couponPropertyPoolDto.setCppId(couponPropertyUserDto.getCppId()); |
| | | couponPropertyPoolDto.setCommunityId(couponPropertyUserDto.getCommunityId()); |
| | | List<CouponPropertyPoolDto> couponPropertyPoolDtos = couponPropertyPoolV1InnerServiceSMOmpl.queryCouponPropertyPools(couponPropertyPoolDto); |
| | | |
| | | Assert.listOnlyOne(couponPropertyPoolDtos, "优惠券不存在"); |
| | | |
| | | String code = GenerateCodeFactory.getUUID(); |
| | | |
| | | CommonCache.setValue(code, couponPropertyUserDto.getCouponId(), CommonCache.PAY_DEFAULT_EXPIRE_TIME); |
| | | |
| | | return new CouponQrCodeDto(couponPropertyUserDto.getCouponId(), code, couponPropertyPoolDtos.get(0).getRemark()); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.acct.coupon.goods; |
| | | |
| | | import com.java110.acct.coupon.AbstractCouponAdapt; |
| | | import com.java110.acct.coupon.ICouponAdapt; |
| | | import com.java110.dto.couponPropertyPool.CouponPropertyPoolDto; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.dto.supplier.SupplierDto; |
| | | import com.java110.dto.supplierCoupon.SupplierCouponDto; |
| | | import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO; |
| | | import com.java110.intf.acct.ISupplierCouponV1InnerServiceSMO; |
| | | import com.java110.intf.scm.ISupplierV1InnerServiceSMO; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component(ICouponAdapt.COUPON_PRE + "1001") |
| | | public class ThridGoodsCouponAdapt extends AbstractCouponAdapt { |
| | | |
| | | /** |
| | | * 供应商 |
| | | */ |
| | | @Autowired |
| | | private ISupplierV1InnerServiceSMO supplierV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto) { |
| | | //非法调入 |
| | | if (StringUtil.isEmpty(couponPropertyUserDto.getCouponId())) { |
| | | return super.generatorQrcode(couponPropertyUserDto); |
| | | } |
| | | |
| | | return supplierV1InnerServiceSMOImpl.generatorQrcode(couponPropertyUserDto); |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.scm.cmd.supplierDoc; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.doc.annotation.*; |
| | | import com.java110.utils.exception.CmdException; |
| | | |
| | | import java.text.ParseException; |
| | | |
| | | |
| | | @Java110CmdDoc(title = "优惠券二维码", |
| | | description = "调用第三方供应商系统获取优惠券二维码", |
| | | httpMethod = "post", |
| | | url = "admin 账户 供应商 自主设置", |
| | | resource = "scmDoc", |
| | | author = "吴学文", |
| | | serviceCode = "supplier.supplierCouponQrcode" |
| | | ) |
| | | |
| | | @Java110ParamsDoc(params = { |
| | | @Java110ParamDoc(name = "businessKey", length = 30, remark = "业务ID"), |
| | | @Java110ParamDoc(name = "suppilerId", length = 30, remark = "供应商ID"), |
| | | @Java110ParamDoc(name = "couponName", length = 30, remark = "优惠券名称"), |
| | | @Java110ParamDoc(name = "couponId", length = 30, remark = "优惠券ID"), |
| | | }) |
| | | |
| | | @Java110ResponseDoc( |
| | | params = { |
| | | @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"), |
| | | @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"), |
| | | @Java110ParamDoc(name = "data", type = "Object", remark = "有效数据"), |
| | | @Java110ParamDoc(parentNodeName = "data",name = "qrCode", type = "String", remark = "二维码内容"), |
| | | @Java110ParamDoc(parentNodeName = "data",name = "remark", type = "String", remark = "核销流程说明"), |
| | | } |
| | | ) |
| | | |
| | | @Java110ExampleDoc( |
| | | reqBody="{'businessKey':'123123','suppilerId':'123123','couponName':'123123','couponId':'123123'}", |
| | | resBody="{'code':0,'msg':'成功','data':{'qrCode':'123123','remark':7200}}" |
| | | ) |
| | | @Java110Cmd(serviceCode = "supplier.supplierCouponQrcode") |
| | | public class SupplierCouponQrcodeCmd extends Cmd{ |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.scm.cmd.supplierDoc; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.doc.annotation.*; |
| | | import com.java110.utils.exception.CmdException; |
| | | |
| | | import java.text.ParseException; |
| | | |
| | | @Java110CmdDoc(title = "调用第三方供应商系统获取token", |
| | | description = "appId 和 appSecure 还有 调用地址可以到admin账户添加供应商时设置", |
| | | httpMethod = "post", |
| | | url = "自主设置", |
| | | resource = "scmDoc", |
| | | author = "吴学文", |
| | | serviceCode = "supplier.getToken" |
| | | ) |
| | | |
| | | @Java110ParamsDoc(params = { |
| | | @Java110ParamDoc(name = "appId", length = 30, remark = "第三方系统APPID"), |
| | | @Java110ParamDoc(name = "appSecure", length = 30, remark = "第三方系统appSecure"), |
| | | }) |
| | | |
| | | @Java110ResponseDoc( |
| | | params = { |
| | | @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"), |
| | | @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"), |
| | | @Java110ParamDoc(name = "data", type = "Object", remark = "有效数据"), |
| | | @Java110ParamDoc(parentNodeName = "data",name = "accessToken", type = "String", remark = "token"), |
| | | @Java110ParamDoc(parentNodeName = "data",name = "expiresIn", type = "String", remark = "过期时间(秒)"), |
| | | } |
| | | ) |
| | | |
| | | @Java110ExampleDoc( |
| | | reqBody="{'appId':'123123','appSecure':'123123'}", |
| | | resBody="{'code':0,'msg':'成功','data':{'accessToken':'123123','expiresIn':7200}}" |
| | | ) |
| | | @Java110Cmd(serviceCode = "supplier.getToken") |
| | | public class SupplierTokenCmd extends Cmd{ |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { |
| | | |
| | | } |
| | | } |
| | |
| | | package com.java110.scm.smo.impl; |
| | | |
| | | |
| | | import com.java110.dto.couponPropertyPool.CouponPropertyPoolDto; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.dto.supplierCoupon.SupplierCouponDto; |
| | | import com.java110.intf.acct.ICouponPropertyPoolV1InnerServiceSMO; |
| | | import com.java110.intf.acct.ISupplierCouponV1InnerServiceSMO; |
| | | import com.java110.scm.dao.ISupplierV1ServiceDao; |
| | | import com.java110.intf.scm.ISupplierV1InnerServiceSMO; |
| | | import com.java110.dto.supplier.SupplierDto; |
| | | import com.java110.po.supplier.SupplierPo; |
| | | import com.java110.scm.supplier.ISupplierAdapt; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.dto.user.UserDto; |
| | |
| | | |
| | | @Autowired |
| | | private ISupplierV1ServiceDao supplierV1ServiceDaoImpl; |
| | | |
| | | @Autowired |
| | | private ICouponPropertyPoolV1InnerServiceSMO couponPropertyPoolV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ISupplierCouponV1InnerServiceSMO supplierCouponV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | @Override |
| | |
| | | public int querySuppliersCount(@RequestBody SupplierDto supplierDto) { |
| | | return supplierV1ServiceDaoImpl.querySuppliersCount(BeanConvertUtil.beanCovertMap(supplierDto)); } |
| | | |
| | | @Override |
| | | public CouponQrCodeDto generatorQrcode(@RequestBody CouponPropertyUserDto couponPropertyUserDto) { |
| | | |
| | | CouponPropertyPoolDto couponPropertyPoolDto = new CouponPropertyPoolDto(); |
| | | couponPropertyPoolDto.setCppId(couponPropertyUserDto.getCppId()); |
| | | couponPropertyPoolDto.setCommunityId(couponPropertyUserDto.getCommunityId()); |
| | | List<CouponPropertyPoolDto> couponPropertyPoolDtos = couponPropertyPoolV1InnerServiceSMOImpl.queryCouponPropertyPools(couponPropertyPoolDto); |
| | | |
| | | Assert.listOnlyOne(couponPropertyPoolDtos, "优惠券不存在"); |
| | | |
| | | |
| | | SupplierCouponDto supplierCouponDto = new SupplierCouponDto(); |
| | | supplierCouponDto.setCouponId(couponPropertyPoolDtos.get(0).getFromId()); |
| | | List<SupplierCouponDto> supplierCouponDtos = supplierCouponV1InnerServiceSMOImpl.querySupplierCoupons(supplierCouponDto); |
| | | |
| | | Assert.listOnlyOne(supplierCouponDtos,"供应商优惠券不存在"); |
| | | |
| | | SupplierDto supplierDto = new SupplierDto(); |
| | | supplierDto.setSupplierId(supplierCouponDtos.get(0).getSupplierId()); |
| | | List<SupplierDto> supplierDtos = querySuppliers(supplierDto); |
| | | Assert.listOnlyOne(supplierDtos,"供应商不存在:"+supplierCouponDtos.get(0).getSupplierId()); |
| | | |
| | | ISupplierAdapt supplierAdapt = ApplicationContextFactory.getBean(supplierDtos.get(0).getBeanName(),ISupplierAdapt.class); |
| | | return supplierAdapt.generatorQrcode(couponPropertyUserDto,supplierDtos.get(0),supplierCouponDtos.get(0)); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.java110.scm.supplier; |
| | | |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.dto.supplier.SupplierDto; |
| | | import com.java110.dto.supplierCoupon.SupplierCouponDto; |
| | | |
| | | public interface ISupplierAdapt { |
| | | |
| | | /** |
| | | * 生成核销 码 |
| | | * @param couponPropertyUserDto |
| | | * @param supplierDto |
| | | * @param supplierCouponDto |
| | | * @return |
| | | */ |
| | | CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto, SupplierDto supplierDto, SupplierCouponDto supplierCouponDto); |
| | | } |
| New file |
| | |
| | | package com.java110.scm.supplier.defaultSupplier; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.dto.couponPropertyUser.CouponPropertyUserDto; |
| | | import com.java110.dto.couponPropertyUser.CouponQrCodeDto; |
| | | import com.java110.dto.supplier.SupplierDto; |
| | | import com.java110.dto.supplierConfig.SupplierConfigDto; |
| | | import com.java110.dto.supplierCoupon.SupplierCouponDto; |
| | | import com.java110.intf.scm.ISupplierConfigV1InnerServiceSMO; |
| | | import com.java110.scm.supplier.ISupplierAdapt; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Component(value = "defaultSupplierAdapt") |
| | | public class DefaultSupplierAdapt implements ISupplierAdapt { |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate outRestTemplate; |
| | | |
| | | @Autowired |
| | | private ISupplierConfigV1InnerServiceSMO supplierConfigV1InnerServiceSMOImpl; |
| | | |
| | | /** |
| | | * 生成优惠券核销码 |
| | | * |
| | | * @param couponPropertyUserDto |
| | | * @param supplierDto |
| | | * @param supplierCouponDto |
| | | * @return |
| | | */ |
| | | @Override |
| | | public CouponQrCodeDto generatorQrcode(CouponPropertyUserDto couponPropertyUserDto, SupplierDto supplierDto, SupplierCouponDto supplierCouponDto) { |
| | | |
| | | SupplierConfigDto supplierConfigDto = new SupplierConfigDto(); |
| | | supplierConfigDto.setSupplierId(supplierDto.getSupplierId()); |
| | | List<SupplierConfigDto> supplierConfigDtos = supplierConfigV1InnerServiceSMOImpl.querySupplierConfigs(supplierConfigDto); |
| | | |
| | | |
| | | JSONObject paramIn = new JSONObject(); |
| | | paramIn.put("businessKey", supplierCouponDto.getBusinessKey()); |
| | | paramIn.put("suppilerId", supplierDto.getSupplierId()); |
| | | paramIn.put("couponName", supplierCouponDto.getName()); |
| | | paramIn.put("couponId", supplierCouponDto.getCouponId()); |
| | | |
| | | JSONObject paramOut = DefaultSupplierFactory.execute(outRestTemplate, paramIn, |
| | | DefaultSupplierFactory.getConfigValue(supplierConfigDtos, |
| | | DefaultSupplierFactory.COUPON_QRCODE_URL), supplierConfigDtos); |
| | | |
| | | CouponQrCodeDto couponQrCodeDto = paramOut.toJavaObject(CouponQrCodeDto.class); |
| | | |
| | | return couponQrCodeDto; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.java110.scm.supplier.defaultSupplier; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.supplierConfig.SupplierConfigDto; |
| | | import com.java110.utils.cache.CommonCache; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.http.*; |
| | | import org.springframework.web.client.HttpStatusCodeException; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class DefaultSupplierFactory { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(DefaultSupplierFactory.class); |
| | | |
| | | //应用ID |
| | | public static final String APP_ID = "APP_ID"; |
| | | |
| | | //应用秘钥 |
| | | public static final String APP_SECURE = "APP_SECURE"; |
| | | |
| | | public static final String TOKEN_URL = "TOKEN_URL"; |
| | | public static final String COUPON_QRCODE_URL = "COUPON_QRCODE_URL"; |
| | | |
| | | |
| | | /** |
| | | * 封装头信息 |
| | | * |
| | | * @return |
| | | */ |
| | | private static HttpHeaders getHeaders(RestTemplate outRestTemplate, List<SupplierConfigDto> supplierConfigDtos) { |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | httpHeaders.add("access-token", get(outRestTemplate, false, supplierConfigDtos)); |
| | | //httpHeaders.add("Content-Type", "application/x-www-form-urlencoded"); |
| | | return httpHeaders; |
| | | } |
| | | |
| | | public static String get(RestTemplate restTemplate, boolean refreshAccessToken, List<SupplierConfigDto> supplierConfigDtos) { |
| | | String appId = getConfigValue(supplierConfigDtos, APP_ID); |
| | | String appSecure = getConfigValue(supplierConfigDtos, APP_SECURE); |
| | | String tokenUrl = getConfigValue(supplierConfigDtos, TOKEN_URL); |
| | | |
| | | String token = CommonCache.getValue(appId + "_ACCESS_TOKEN"); |
| | | if (!StringUtil.isEmpty(token) && !refreshAccessToken) { |
| | | return token; |
| | | } |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | JSONObject param = new JSONObject(); |
| | | param.put("appId", appId); |
| | | param.put("appSecure", appSecure); |
| | | HttpEntity httpEntity = new HttpEntity(param, headers); |
| | | ResponseEntity<String> tokenRes = restTemplate.exchange(tokenUrl, HttpMethod.POST, httpEntity, String.class); |
| | | |
| | | if (tokenRes.getStatusCode() != HttpStatus.OK) { |
| | | throw new IllegalArgumentException("获取token失败" + tokenRes.getBody()); |
| | | } |
| | | JSONObject tokenObj = JSONObject.parseObject(tokenRes.getBody()); |
| | | |
| | | if (!tokenObj.containsKey("code") || ResultVo.CODE_OK != tokenObj.getInteger("code")) { |
| | | throw new IllegalArgumentException("获取token失败" + tokenRes.getBody()); |
| | | } |
| | | |
| | | token = tokenObj.getJSONObject("data").getString("accessToken"); |
| | | int expiresIn = tokenObj.getJSONObject("data").getInteger("expiresIn"); |
| | | |
| | | CommonCache.setValue(appId + "_ACCESS_TOKEN", token, expiresIn - 200); |
| | | |
| | | return token; |
| | | } |
| | | |
| | | public static String getConfigValue(List<SupplierConfigDto> supplierConfigDtos, String key) { |
| | | for (SupplierConfigDto supplierConfigDto : supplierConfigDtos) { |
| | | if (supplierConfigDto.getColumnKey().equals(key)) { |
| | | return supplierConfigDto.getColumnValue(); |
| | | } |
| | | } |
| | | |
| | | return ""; |
| | | } |
| | | |
| | | public static JSONObject execute(RestTemplate outRestTemplate, JSONObject param, String url, List<SupplierConfigDto> supplierConfigDtos) { |
| | | ResponseEntity<String> responseEntity = null; |
| | | HttpEntity httpEntity = null; |
| | | JSONObject paramOut = null; |
| | | try { |
| | | httpEntity = new HttpEntity(param.toJSONString(), getHeaders(outRestTemplate, supplierConfigDtos)); |
| | | responseEntity = outRestTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | paramOut = JSONObject.parseObject(responseEntity.getBody()); |
| | | |
| | | if (paramOut.getInteger("code") != ResultVo.CODE_OK) { |
| | | throw new CmdException(paramOut.getString("msg")); |
| | | } |
| | | } catch (HttpStatusCodeException e) { |
| | | logger.error("请求失败" + e.getResponseBodyAsString(), e); |
| | | throw e; |
| | | } catch (Exception e){ |
| | | logger.error("请求失败", e); |
| | | throw e; |
| | | }finally { |
| | | logger.debug("请求url:{},请求报文:{},返回报文:{}", url, httpEntity, responseEntity); |
| | | } |
| | | |
| | | return paramOut; |
| | | } |
| | | |
| | | } |