Commit 2885edec authored by qinhu's avatar qinhu

---正式版

parent c60b19cd
package cn.wise.sc.pay.common.core.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -7,6 +10,7 @@ import java.util.Date;
* @author: qh
* @create: 2019-12-12 14:40
**/
@Data
public class TransactionMessage {
// 消息ID
private Long id;
......@@ -28,11 +32,17 @@ public class TransactionMessage {
// 发送次数,每重新发送一次+1
private int sendCount;
// 消息创建时间
private Date createDate = new Date();
/**
* 创建时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
// 最近发送消息时间,每发送一次更新时间
private Date sendDate;
/**
* 最近发送消息时间
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime sendDate;
// 状态:0等待消费 1已消费 2已死亡
private int status = 0;
......@@ -97,19 +107,19 @@ public class TransactionMessage {
this.sendCount = sendCount;
}
public Date getCreateDate() {
return createDate;
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public Date getSendDate() {
public LocalDateTime getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
public void setSendDate(LocalDateTime sendDate) {
this.sendDate = sendDate;
}
......@@ -152,4 +162,27 @@ public class TransactionMessage {
public void setDieDate(Date dieDate) {
this.dieDate = dieDate;
}
/**
* 创建消息
*
* @param routeKey 路由
* @param msg 消息
* @param paas 发送平台
* @return
*/
public static TransactionMessage createTransactionMessage(String routeKey, String msg, String paas) {
TransactionMessage transactionMessage = getInstance();
transactionMessage.setSendCount(5);
transactionMessage.setCreateTime(LocalDateTime.now());
transactionMessage.setMessage(msg);
transactionMessage.setStatus(0);
transactionMessage.setSendSystem(paas);
return transactionMessage;
}
public static TransactionMessage getInstance() {
return new TransactionMessage();
}
}
......@@ -33,13 +33,12 @@ public class JdbcConfig {
public DataSource createDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://81.68.92.175:3306/oxo_main_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/oxo_main_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
dataSource.setUsername("root");
dataSource.setPassword("admin!@#123");
return dataSource;
}
/**
* OpenApi的token验证
* 使用的是设备绑定表里面的设备号登录 oxo_merchant库device表 deviceNo登录
......@@ -48,7 +47,7 @@ public class JdbcConfig {
public static DataSource createDataSourceDevice(){
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://81.68.92.175:3306/oxo_merchant?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/oxo_merchant?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
dataSource.setUsername("root");
dataSource.setPassword("admin!@#123");
return dataSource;
......
......@@ -171,7 +171,14 @@ public interface IGoodsService extends IService<Goods> {
/**
* 批量添加
* @param goods 商品集合
* @return
* @return Boolean
*/
BaseResponse<Boolean> batchAdd(List<Goods> goods);
/**
* 根据ids获取商品集合
* @param ids id集合
* @return list
*/
List<Goods> getByGoodIds(List<Long> ids);
}
......@@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -533,4 +532,13 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
public BaseResponse<Boolean> batchAdd(List<Goods> goods) {
return BaseResponse.ok(this.saveBatch(goods));
}
@Override
public List<Goods> getByGoodIds(List<Long> ids) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.in("id",ids);
return this.list(queryWrapper);
}
}
......@@ -32,7 +32,7 @@ public class Producer {
public void createQueue(String queueName) throws IOException {
Connection conn =connectionFactory.createConnection();
Channel channel = conn.createChannel(false);
channel.queueDeclare(queueName, true, false, false, null);
channel.queueDeclare(queueName, true, false, true, null);
//声明交换机
channel.exchangeDeclare("paycallback", "direct");
//绑定队列到交换机
......
......@@ -273,6 +273,7 @@ public class UserControler extends UserController {
BaseResponse<Membership> primaryMemberShip = memberShipService.getPrimaryMemberShip();
Membership membership = primaryMemberShip.getData();
if (primaryMemberShip.getCode() == 400 || membership == null) {
super.userDel(sysUserBuild.getUserId());
return BaseResponse.error("绑定会员失败,注册失败", SysUser.class.getName());
}
//新增成功时 给用户关联一个新的 积分、经验、会员等级信息
......
......@@ -29,7 +29,7 @@ spring:
prefix: app_
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
url: jdbc:mysql://81.68.92.175:3306/oxo_main_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://127.0.0.1:3306/oxo_main_data?useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: admin!@#123
driver-class-name: com.mysql.cj.jdbc.Driver
......
......@@ -39,7 +39,11 @@
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-actuator</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>common-redis</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
......
......@@ -12,6 +12,7 @@ import cn.wise.sc.pay.laas.userbac.domain.dto.UserInfo;
import cn.wise.sc.pay.laas.userbac.domain.entity.SysRole;
import cn.wise.sc.pay.laas.userbac.domain.entity.SysUser;
import cn.wise.sc.pay.pass.business.cashiers.config.CommonUrlProperties;
import cn.wise.sc.pay.pass.business.cashiers.model.CheckPasswordQuery;
import cn.wise.sc.pay.pass.business.cashiers.model.Employee;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
......@@ -20,13 +21,16 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -59,6 +63,8 @@ public class UserControler extends UserController {
RoleController roleController;
@Autowired
CommonUrlProperties commonUrlProperties;
@Autowired
IMerchantService iMerchantService;
@ApiOperation("收银端注册账号")
@PostMapping("/register")
......@@ -156,4 +162,11 @@ public class UserControler extends UserController {
}
}
@PostMapping("/check/pwd")
@ApiOperation("验证敏感操作密码")
public BaseResponse<Boolean> checkPwd(@RequestBody CheckPasswordQuery checkPasswordQuery) {
return iMerchantService.checkPwd(checkPasswordQuery.getSeller(),checkPasswordQuery.getPwd());
}
}
package cn.wise.sc.pay.pass.business.cashiers.controller.merchant;
import cn.wise.sc.pay.api.merchant.service.IMerchDiscountService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 店铺折扣
* @author: qh
* @create: 2020-09-07 13:36
**/
@RestController
@CrossOrigin
@RequestMapping("/merchant/discount")
@Slf4j
public class MerchDiscountController {
final
IMerchDiscountService iMerchDiscountService;
public MerchDiscountController(IMerchDiscountService iMerchDiscountService) {
this.iMerchDiscountService = iMerchDiscountService;
}
@GetMapping("/{seller}")
@ApiOperation("根据商户id获取折扣配置")
@ApiImplicitParam(name = "seller", value = "商户id")
BaseResponse<MerchDiscount> getMerchDiscountBySeller(@PathVariable("seller") Long seller){
return iMerchDiscountService.getMerchDiscountBySeller(seller);
}
@PutMapping
@ApiOperation("更新商户折扣信息")
BaseResponse<Boolean> updateMerchDiscountBySeller(@RequestBody MerchDiscount merchDiscount){
return iMerchDiscountService.updateMerchDiscountBySeller(merchDiscount);
}
@PostMapping
@ApiOperation("新增一个折扣信息")
BaseResponse<MerchDiscount> addNewMerchDiscount(@RequestBody MerchDiscount merchDiscount){
return iMerchDiscountService.addNewMerchDiscount(merchDiscount);
}
}
package cn.wise.sc.pay.pass.business.cashiers.model;
import lombok.Data;
/**
* @description:
* @author: qh
* @create: 2020-09-07 17:21
**/
@Data
public class CheckPasswordQuery {
private String seller;
private String pwd;
}
package cn.wise.sc.pay.pass.business.cashiers.model;
import lombok.Data;
import java.math.BigDecimal;
/**
* @description: 商品核销
* @author: qh
* @create: 2020-06-12 15:14
**/
@Data
public class GoodMarketVo {
private String name;
private BigDecimal totalPrice;
private Integer sold;
private Long id;
private String type;
}
......@@ -31,6 +31,7 @@ import javax.mail.MessagingException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;
......@@ -146,6 +147,7 @@ public class IPaasOrderServiceImpl implements IPaasOrderService {
public BaseResponse editOrder(OrderDetailQuery orderQuery) {
return iOrderService.editOrder(orderQuery);
}
@Override
public BaseResponse cancelOrder(String orderNo) {
return iOrderService.cancelOrder(orderNo);
......@@ -247,16 +249,14 @@ public class IPaasOrderServiceImpl implements IPaasOrderService {
//判断发送邮件的必备条件
HashMap<String, BigDecimal> rts = hashMapBaseResponse.getData();
List<HashMap> list = (List<HashMap>) merchResponse.getData();
LinkedHashMap list = (LinkedHashMap) merchResponse.getData();
if (list.size() == 0 || rts.size() == 0) {
return BaseResponse.error("发送失败!", this.getClass().getName());
}
String email = "";
for (HashMap hashMap : list) {
Merchant merchant = BeanUtil.mapToBean(hashMap, Merchant.class, true);
assert merchant != null;
email = merchant.getLinkEmail();
}
Merchant merchant = BeanUtil.mapToBean(list, Merchant.class, true);
assert merchant != null;
email = merchant.getLinkEmail();
//发送邮件
try {
......@@ -266,7 +266,12 @@ public class IPaasOrderServiceImpl implements IPaasOrderService {
} catch (MessagingException e) {
return BaseResponse.error("发送失败!", this.getClass().getName());
}
try {
sendMail(new HashMap(),"2862695792@qq.com");
mailService.sendSimpleMail("2862695792@qq.com", "_商品统计", "sssssss");
} catch (MessagingException e) {
e.printStackTrace();
}
return BaseResponse.okMsg("发送成功!", this.getClass());
}
......@@ -280,10 +285,10 @@ public class IPaasOrderServiceImpl implements IPaasOrderService {
return;
}
Context context = new Context();
context.setVariable("aggregate", map.get("Aggregate"));
context.setVariable("money", map.get("Money"));
context.setVariable("discount", map.get("Discounts"));
context.setVariable("aaaa","aaaa");
// context.setVariable("aggregate", map.get("Aggregate"));
// context.setVariable("money", map.get("Money"));
// context.setVariable("discount", map.get("Discounts"));
String emailTemplate = templateEngine.process("welcome", context);
String dateTime = DateUtil.formatDate(DateUtil.date());
......
......@@ -10,13 +10,14 @@ spring:
nacos:
discovery:
server-addr: ${nacos.ip}:8848
# namespace: 34ec6c41-14f8-4f0f-a565-6039e5c49b22
config:
server-addr: ${nacos.ip}:8848
file-extension: yaml
#共享文件设置
shared-dataids: common.yaml
refreshable-dataids: common.yaml
# namespace: 34ec6c41-14f8-4f0f-a565-6039e5c49b22
#变量名字
nacos:
ip: 81.68.92.175 #nacosd地址
......
......@@ -33,12 +33,6 @@
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--dubbo-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-dubbo</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
......@@ -53,10 +47,6 @@
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>laas-goods</artifactId>
......@@ -95,12 +85,6 @@
<artifactId>bcprov-jdk15on</artifactId>
<version>1.51</version>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>payment-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>association-api</artifactId>
......
......@@ -27,7 +27,7 @@ public class MerchantProfitController {
this.merchantProfitService = merchantProfitService;
}
@GetMapping("/moneyByStrategy")
@GetMapping("/")
@ApiOperation(value = "根据店铺id查询相关分润额")
@ApiImplicitParams({
@ApiImplicitParam(name = "merchantId",value = "商户id",paramType = "query",dataType = "Long"),
......
......@@ -2,20 +2,24 @@ package cn.wise.sc.pay.pass.business.manager.controller.order;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.pay.api.order.service.IOrdersService;
import cn.wise.sc.pay.api.order.service.ISafeguardService;
import cn.wise.sc.pay.api.order.service.IZHPaymentService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.common.core.query.PageQuery;
import cn.wise.sc.pay.common.core.query.PageWrapperQuery;
import cn.wise.sc.pay.common.core.query.PageWrapperQueryUtil;
import cn.wise.sc.pay.domain.order.SafeguardUtil;
import cn.wise.sc.pay.domain.order.model.Orders;
import cn.wise.sc.pay.domain.order.model.Safeguard;
import cn.wise.sc.pay.domain.order.model.SafeguardStatus;
import cn.wise.sc.pay.domain.order.query.SafeguardDetailQuery;
import cn.wise.sc.payment.api.service.IZHPaymentService;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -44,11 +48,16 @@ public class SafeguardController {
final ISafeguardService iSafeguardService;
final IZHPaymentService izhPaymentService;
final
IOrdersService iOrdersService;
public SafeguardController(
ISafeguardService iSafeguardService, IZHPaymentService izhPaymentService) {
ISafeguardService iSafeguardService,
IZHPaymentService izhPaymentService,
IOrdersService iOrdersService) {
this.iSafeguardService = iSafeguardService;
this.izhPaymentService = izhPaymentService;
this.iOrdersService = iOrdersService;
}
@PutMapping("/audit")
......@@ -112,8 +121,15 @@ public class SafeguardController {
Safeguard safeguard = BeanUtil.mapToBean(map, Safeguard.class, true);
// 发起退款申请
String amount = new Double(safeguard.getAmount() * 100).intValue() + "";
Map<String, String> map1 = new HashedMap(1);
map1.put("unified_order_no", safeguard.getOrderNo());
Orders data = iOrdersService.getOneOrder(JSON.toJSONString(map1)).getData();
if (data == null) {
return BaseResponse.error("退款失败!", null);
}
return izhPaymentService.applyForRefund(
safeguard.getRefundNo(), safeguard.getOrderNo(), amount, amount, safeguard.getReason());
safeguard.getRefundNo(), safeguard.getOrderNo(), amount, amount, safeguard.getReason(), data.getSellerId() + ""
);
}
return refundDetailsResponse;
} else {
......
package cn.wise.sc.pay.pass.business.manager.controller.order;
import cn.wise.sc.pay.api.order.service.IZHPayMerService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.order.model.MerchantPayPro;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @author: qh
* @create: 2020-09-24 12:54
**/
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/pay/setting")
public class ZHPaysettingController {
@Autowired
IZHPayMerService iMerchantPayProService;
@PostMapping("/create")
public BaseResponse<Boolean> create(@RequestBody MerchantPayPro merchantPayPro) {
return iMerchantPayProService.create(merchantPayPro);
}
@DeleteMapping("/{id}")
public BaseResponse<Boolean> delete(@PathVariable("id") Long id) {
return iMerchantPayProService.delete(id);
}
@GetMapping("/{sellerId}")
public BaseResponse<MerchantPayPro> getBySeller(@PathVariable("sellerId") Long sellerId) {
return iMerchantPayProService.getBySeller(sellerId);
}
}
spring:
main:
allow-bean-definition-overriding: true
......@@ -11,12 +10,14 @@ spring:
nacos:
discovery:
server-addr: ${nacos.ip}:8848
# namespace: 34ec6c41-14f8-4f0f-a565-6039e5c49b22
config:
server-addr: ${nacos.ip}:8848
file-extension: yaml
#共享文件设置
shared-dataids: common.yaml
refreshable-dataids: common.yaml
# namespace: 34ec6c41-14f8-4f0f-a565-6039e5c49b22
#变量名字
nacos:
......
......@@ -16,7 +16,7 @@ import cn.wise.sc.pay.domain.order.query.OrderDetailQuery;
import cn.wise.sc.pay.paas.open.api.OpenApiApplication;
import cn.wise.sc.pay.paas.open.api.model.OrdersVO;
import cn.wise.sc.pay.paas.open.api.service.IPaasOrderService;
import cn.wise.sc.payment.api.service.IZHPaymentService;
import cn.wise.sc.pay.api.order.service.IZHPaymentService;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiImplicitParam;
......@@ -237,7 +237,7 @@ public class OrderOpenApiController {
if (orderStatus != null) {
OrderStatus status = OrderStatusUtils.getStatus(orderStatus);
if (!OrderStatus.ALL.name().equals(status.name())){
if (!OrderStatus.ALL.name().equals(status.name())) {
eq.put("order_status", OrderStatusUtils.getStatus(orderStatus));
}
}
......@@ -335,7 +335,10 @@ public class OrderOpenApiController {
OrderResponse response = iOrderService.getOneOrder(JSON.toJSONString(condition));
if (response.getCode() == 200) {
Orders order = response.getData();
BaseResponse response1 = izhPaymentService.applyForRefund(refundNo, orderNo, order.getPayPrice().multiply(new BigDecimal(100)).intValue() + "", order.getPayPrice().multiply(new BigDecimal(100)).intValue() + "", "");
BaseResponse response1 = izhPaymentService.applyForRefund(refundNo, orderNo,
order.getPayPrice().multiply(new BigDecimal(100)).intValue() + "",
order.getPayPrice().multiply(new BigDecimal(100)).intValue() + "", "",
order.getSellerId() + "");
return response1;
} else {
return response;
......
......@@ -32,7 +32,7 @@ public class Producer {
public void createQueue(String queueName) throws IOException {
Connection conn =connectionFactory.createConnection();
Channel channel = conn.createChannel(false);
channel.queueDeclare(queueName, true, false, false, null);
channel.queueDeclare(queueName, true, false, true, null);
//声明交换机
channel.exchangeDeclare(queueName, "direct");
//绑定队列到交换机
......
......@@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
......@@ -271,5 +270,13 @@ public interface IGoodsService {
*/
@GetMapping("/allGoodsSpc")
List<GoodsSpecExcel> getAllGoodsSpc();
/**
* 获取商品列表 根据ids
* @param ids id集合
* @return List
*/
@PostMapping("/goodIds")
List<Goods> getByGoodIds(@RequestBody List<Long> ids);
}
......@@ -135,7 +135,6 @@ public class GoodsServiceImplHystrix implements IGoodsService {
@Override
public BaseResponse<Goods> scanAddGoods(GoodsScanQuery goodsScanQuery) {
error();
return null;
}
......@@ -156,6 +155,11 @@ public class GoodsServiceImplHystrix implements IGoodsService {
return null;
}
@Override
public List<Goods> getByGoodIds(List<Long> ids) {
return null;
}
/**
* 服务异常
......@@ -163,7 +167,6 @@ public class GoodsServiceImplHystrix implements IGoodsService {
* @return
*/
private BaseResponse error() {
throw new RuntimeException("服务异常,请检查服务状态!");
}
}
......@@ -22,16 +22,13 @@ import cn.wise.sc.pay.common.core.query.PageQuery;
import cn.wise.sc.pay.domain.merchant.bean.Merchant;
import com.alibaba.excel.EasyExcelFactory;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
......@@ -437,4 +434,9 @@ public class GoodsController {
public BaseResponse<Goods> getGoodsInfoByCode(String code) {
return iGoodsService.getGoodsInfoByCode(code);
}
@PostMapping("/goodIds")
public List<Goods> getByGoodIds(@RequestBody List<Long> ids){
return iGoodsService.getByGoodIds(ids);
}
}
package cn.wise.sc.pay.business.cashier.controller;
import cn.wise.sc.pay.api.merchant.service.IMerchantService;
import cn.wise.sc.pay.api.order.service.IOrdersService;
import cn.wise.sc.pay.business.cashier.service.IPaasOrderService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.common.core.query.PageQuery;
......@@ -21,7 +22,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -39,13 +42,17 @@ public class OrderController {
IPaasOrderService iOrderService;
final
IMerchantService iMerchantService;
final
IOrdersService iOrdersService;
public OrderController(IMerchantService iMerchantService, IPaasOrderService iOrderService) {
public OrderController(IMerchantService iMerchantService,
IPaasOrderService iOrderService,
IOrdersService iOrdersService) {
this.iMerchantService = iMerchantService;
this.iOrderService = iOrderService;
this.iOrdersService = iOrdersService;
}
@PostMapping("/new")
@ApiOperation("新增一个订单")
@ApiImplicitParam(name = "orderQuery", value = "订单请求", paramType = "body", dataType = "OrderQuery")
......@@ -66,12 +73,10 @@ public class OrderController {
@ApiOperation("挂单")
@ApiImplicitParam(name = "orderQuery", value = "订单请求", paramType = "body", dataType = "OrderQuery")
public BaseResponse newEntryOrder(@RequestBody OrderDetailQuery orderQuery) {
orderQuery.setStatus(OrderStatus.ENTRY_ORDER.name());
return iOrderService.createOrder(orderQuery);
}
@PutMapping("/entry")
@ApiOperation("修改挂单信息")
@ApiImplicitParam(name = "orderQuery", value = "订单请求", paramType = "body", dataType = "OrderQuery")
......@@ -94,11 +99,9 @@ public class OrderController {
BaseResponse responseEntity;
Map<String, Object> condition = new HashMap<>();
condition.put("user_id", userId);
OrderStatus orderStatus = OrderStatusUtils.getStatus(status);
condition.put("order_status", orderStatus.name());
responseEntity = iOrderService.getOrders(condition);
return responseEntity;
}
......@@ -138,14 +141,12 @@ public class OrderController {
@ApiOperation("支付订单")
@ApiImplicitParam(name = "orderNo", value = "订单号儿", paramType = "path", dataType = "String")
public BaseResponse payOrder(@PathVariable("orderNo") String orderNo) {
return iOrderService.payOrder(orderNo);
}
@GetMapping("/orderNo")
@ApiOperation("获取订单号")
public BaseResponse getOrderNo() {
return BaseResponse.ok(iOrderService.getPreOrderNo());
}
......@@ -198,6 +199,28 @@ public class OrderController {
BaseResponse baseResponse = iOrderService.orderByNo(orderNo);
return baseResponse;
}
/**
* 统计 根据支付类型 统计金额
*/
@GetMapping("/statistics/payMethod/Money")
@ApiOperation("统计 根据支付类型 统计金额")
@ApiImplicitParams({
@ApiImplicitParam(name = "strategy", value = "统计类型 策略 1:每月统计 2:每季度统计 3:每年统计 4:自定义统计 其他默认:每天", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "shopName", value = "商品名", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "start", value = "起始时间", paramType = "query", dataType = "long"),
@ApiImplicitParam(name = "end", value = "结束时间", paramType = "query", dataType = "long")
})
public BaseResponse statisticsMoneyByPatMethod(int strategy, String shopName, long start, long end) {
BaseResponse baseResponse = iOrdersService.statisticsMoneyByPatMethod(strategy, shopName, start, end);
BaseResponse response = iOrdersService.statisticsCountByPatMethod(strategy, shopName, start, end);
if (baseResponse.getCode() == 200 && response.getCode() == 200) {
List<Object> data = new ArrayList<>(2);
data.add(baseResponse.getData());
data.add(response.getData());
return BaseResponse.ok(data);
}
return BaseResponse.error("统计失败!", null);
}
}
......@@ -32,7 +32,7 @@ public class MybatisGenerator {
//设置数据源XpenseTracker
DataSourceConfig dataSourceConfig = new DataSourceConfig();
dataSourceConfig.setUrl("jdbc:mysql://81.68.92.175:3306/oxo_eshopping?useUnicode=true&characterEncoding=UTF-8");
dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/oxo_eshopping?useUnicode=true&characterEncoding=UTF-8");
dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
dataSourceConfig.setUsername("root");
dataSourceConfig.setPassword("admin!@#123");
......
package cn.wise.sc.pay.api.merchant.service;
import cn.wise.sc.pay.api.merchant.service.hystrix.MerchDiscountImpl;
import cn.wise.sc.pay.api.merchant.service.hystrix.MerchantImpl;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @description:
* @author: qh
* @create: 2020-09-07 11:05
**/
@FeignClient(value = "saas-v1-merchant", path = "/merchant/discount", fallback = MerchDiscountImpl.class)
public interface IMerchDiscountService {
@GetMapping("/{seller}")
@ApiOperation("根据商户id获取折扣配置")
@ApiImplicitParam(name = "seller", value = "商户id")
BaseResponse<MerchDiscount> getMerchDiscountBySeller(@PathVariable("seller") Long seller);
@PutMapping
@ApiOperation("更新商户折扣信息")
BaseResponse<Boolean> updateMerchDiscountBySeller(@RequestBody MerchDiscount merchDiscount);
@PostMapping
@ApiOperation("新增一个折扣信息")
BaseResponse<MerchDiscount> addNewMerchDiscount(@RequestBody MerchDiscount merchDiscount);
}
......@@ -127,4 +127,8 @@ public interface IMerchantService {
*/
@PutMapping("storeInfo")
BaseResponse updateStore(@RequestBody StoreVo storeVo);
@PostMapping("/check/pwd")
BaseResponse<Boolean> checkPwd(@RequestParam("seller") String seller,
@RequestParam("pwd") String pwd);
}
......@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
*
* @author qh
*/
@Component
@Component(value = "BankPermitServiceImplHy")
public class BankPermitServiceImpl implements IBankPermitService {
@Override
public ResponseEntity addBankPermit(BankPermitQuery bankPermitQuery) {
......
......@@ -6,7 +6,7 @@ import cn.wise.sc.pay.domain.merchant.bean.BannerImage;
import cn.wise.sc.pay.domain.merchant.query.BannerImageQuery;
import org.springframework.stereotype.Component;
@Component
@Component(value = "BannerImageServiceImplHystrix")
public class BannerImageServiceImpl implements IBannerImageService {
@Override
......
......@@ -7,7 +7,7 @@ import cn.wise.sc.pay.domain.merchant.bean.BannerMenu;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "BannerMenuServiceImplHy")
public class BannerMenuServiceImpl implements IBannerMenuService {
@Override
......
......@@ -6,7 +6,7 @@ import cn.wise.sc.pay.domain.merchant.query.BusinessLicenseQuery;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "businessLicenseImplHystrix")
public class BusinessLicenseImpl implements IBusinessLicenseService {
@Override
......
......@@ -7,7 +7,7 @@ import cn.wise.sc.pay.domain.merchant.query.CategoryQuery;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "CategoryServiceImplHy")
public class CategoryServiceImpl implements ICategoryService {
@Override
public BaseResponse getCategorys() {
......
......@@ -7,7 +7,7 @@ import cn.wise.sc.pay.domain.merchant.bean.Device;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "DeviceServiceImplHy")
public class DeviceServiceImpl implements IDeviceService {
@Override
public BaseResponse getTypeList(String typeName) {
......
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
* @author: lqk
* @create: 2019-12-25
**/
@Component
@Component(value = "DeviceUserImplHy")
public class DeviceUserImpl implements IDeviceUserService {
@Override
......
......@@ -6,7 +6,7 @@ import cn.wise.sc.pay.domain.merchant.query.InstitutionQuery;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "InstitutionServiceImplHy")
public class InstitutionServiceImpl implements IInstitutionService {
@Override
public ResponseEntity addInstitution(InstitutionQuery query) {
......
......@@ -5,7 +5,7 @@ import cn.wise.sc.pay.domain.merchant.bean.Label;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "LabelServiceImplHy")
public class LabelServiceImpl implements ILabelService {
@Override
public ResponseEntity addCategory(String name) {
......
package cn.wise.sc.pay.api.merchant.service.hystrix;
import cn.wise.sc.pay.api.merchant.service.IMerchDiscountService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import org.springframework.stereotype.Component;
/**
* @description:
* @author: qh
* @create: 2020-09-07 11:06
**/
@Component("merchDiscountImplHy")
public class MerchDiscountImpl implements IMerchDiscountService {
@Override
public BaseResponse<MerchDiscount> getMerchDiscountBySeller(Long seller) {
return BaseResponse.error("获取失败!",this.getClass().getName());
}
@Override
public BaseResponse<Boolean> updateMerchDiscountBySeller(MerchDiscount merchDiscount) {
return BaseResponse.error("更新失败!",this.getClass().getName());
}
@Override
public BaseResponse<MerchDiscount> addNewMerchDiscount(MerchDiscount merchDiscount) {
return BaseResponse.error("添加失败!",this.getClass().getName());
}
}
......@@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
* @author: qh
* @create: 2020-06-15 14:56
**/
@Component
@Component(value = "MerchantCommentImplHy")
public class MerchantCommentImpl implements IMerchantCommentService {
@Override
public BaseResponse addComment(Comment comment) {
......
......@@ -17,7 +17,7 @@ import java.util.List;
* @author: lqk
* @create: 2019-12-25
**/
@Component
@Component(value = "MerchantImplHy")
public class MerchantImpl implements IMerchantService {
@Override
......@@ -139,6 +139,12 @@ public class MerchantImpl implements IMerchantService {
return null;
}
@Override
public BaseResponse<Boolean> checkPwd(String seller, String pwd) {
return BaseResponse.ok(false);
}
@Override
public BaseResponse getStoreInfoPage(PageWrapperQuery pageWrapperQuery) {
error();
......
......@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
@Component(value = "MerchantProfitServiceImplHy")
public class MerchantProfitServiceImpl implements IMerchantProfitService {
@Override
......
......@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
* @author: qh
* @create: 2020-06-15 14:57
**/
@Component
@Component(value = "MerchantReplyImplHy")
public class MerchantReplyImpl implements IMerchantReplyService {
@Override
public BaseResponse inserReply(Reply reply) {
......
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Component(value = "ProfitAllocationServiceImplHy")
public class ProfitAllocationServiceImpl implements IProfitAllocationService {
@Override
public BaseResponse addProfit(ProfitAllocation profit) {
......
......@@ -5,7 +5,7 @@ import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.query.StoreQuery;
import org.springframework.stereotype.Component;
@Component
@Component(value = "StoreServiceImplHy")
public class StoreServiceImpl implements IStoreService {
......
......@@ -6,7 +6,7 @@ import cn.wise.sc.pay.domain.merchant.query.TaxCertificateQuery;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
@Component
@Component(value = "TaxCertificateServiceImplHy")
public class TaxCertificateServiceImpl implements ITaxCertificateService {
@Override
......
......@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
* @author: qh
* @create: 2020-06-09 15:55
**/
@Component
@Component(value = "TransportationHubServiceImplHy")
public class TransportationHubServiceImpl implements ITransportationHubService {
@Override
public BaseResponse list(PageWrapperQuery pageWrapperQuery) {
......
......@@ -20,7 +20,6 @@
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package cn.wise.sc.pay.business.merchant;
/**
* @description:
* @author: qh
* @create: 2020-09-13 11:08
**/
public class MerchantRunner {
}
package cn.wise.sc.pay.business.merchant.controller;
import cn.wise.sc.pay.business.merchant.service.IMerchDiscountService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
* @description: 商户折扣控制器
* @author: qh
* @create: 2020-09-07 09:43
**/
@CrossOrigin
@RestController
@Api(tags = "折扣控制器")
@RequestMapping("/merchant/discount")
public class MerchDiscountController {
final
IMerchDiscountService iMerchDiscountService;
public MerchDiscountController(IMerchDiscountService iMerchDiscountService) {
this.iMerchDiscountService = iMerchDiscountService;
}
@GetMapping("/{seller}")
@ApiOperation("根据商户id获取折扣配置")
@ApiImplicitParam(name = "seller",value = "商户id")
public BaseResponse<MerchDiscount> getMerchDiscountBySeller(@PathVariable("seller") Long seller) {
return iMerchDiscountService.getBySellerId(seller);
}
@PutMapping
@ApiOperation("更新商户折扣信息")
public BaseResponse<Boolean> updateMerchDiscountBySeller(@RequestBody MerchDiscount merchDiscount){
return iMerchDiscountService.updateMerchDiscountBySeller(merchDiscount);
}
@PostMapping
@ApiOperation("新增一个折扣信息")
public BaseResponse<MerchDiscount> addNewMerchDiscount(@RequestBody MerchDiscount merchDiscount){
return iMerchDiscountService.addNewMerchDiscount(merchDiscount);
}
public static void main(String[] args) {
MerchDiscount merchDiscount = new MerchDiscount();
merchDiscount.setSellerId(99L);
List<MerchDiscount.DiscountSetting> list = new ArrayList<>();
MerchDiscount.DiscountSetting setting = new MerchDiscount.DiscountSetting();
setting.setDiscount(88D);
setting.setId("1");
MerchDiscount.DiscountSetting setting2 = new MerchDiscount.DiscountSetting();
setting2.setDiscount(88D);
setting2.setId("1");
list.add(setting);
list.add(setting2);
String s = JSON.toJSONString(list);
merchDiscount.setDiscountStr(s);
System.out.println(JSON.toJSONString(merchDiscount));
}
}
......@@ -86,7 +86,7 @@ public class MerchantController extends BaseController<IMerchantService, Merchan
}
@GetMapping("like")
public BaseResponse getMerchList(@RequestParam(value = "merchName",required = false) String merchName) {
public BaseResponse getMerchList(@RequestParam(value = "merchName", required = false) String merchName) {
QueryWrapper wrapper = new QueryWrapper();
if (StringUtils.isNotBlank(merchName)) {
wrapper.like("merch_name", merchName);
......@@ -119,6 +119,7 @@ public class MerchantController extends BaseController<IMerchantService, Merchan
}
return merchantService.updateMerchant(merchant);
}
@PostMapping("getMerchantPage")
public BaseResponse<Page<Merchant>> getMerchantPage(Integer status, String merchantName,
Integer pageNo, Integer pageSize, Long start, Long end) {
......@@ -373,7 +374,19 @@ public class MerchantController extends BaseController<IMerchantService, Merchan
}
@PutMapping("storeInfo")
BaseResponse updateStore(@RequestBody StoreVo storeVo){
BaseResponse updateStore(@RequestBody StoreVo storeVo) {
return merchantService.updateStore(storeVo);
}
/**
* 验证敏感操作密码
*
* @param seller 商户id
* @param pwd 密码
* @return bool
*/
@PostMapping("/check/pwd")
BaseResponse<Boolean> checkPwd(String seller, String pwd) {
return merchantService.checkPwd(seller, pwd);
}
}
package cn.wise.sc.pay.business.merchant.controller;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.wise.sc.pay.business.merchant.service.IMerchantProfitService;
import cn.wise.sc.pay.business.merchant.service.IProfitAllocationService;
......
package cn.wise.sc.pay.business.merchant.mapper;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @description: 商户折扣mapper
* @author: qh
* @create: 2020-09-07 09:39
**/
@Mapper
public interface MerchDiscountMapper extends BaseMapper<MerchDiscount> {
}
<?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.wise.sc.pay.business.merchant.mapper.MerchDiscountMapper">
</mapper>
\ No newline at end of file
package cn.wise.sc.pay.business.merchant.service;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @description:
* @author: qh
* @create: 2020-09-07 09:41
**/
public interface IMerchDiscountService extends IService<MerchDiscount> {
/**
* 获取折扣配 通过seller
*
* @return MerchDiscount
*/
BaseResponse<MerchDiscount> getBySellerId(Long seller);
/**
* 更新商户折扣 商户id
* @param merchDiscount 商户折扣
* @return MerchDiscount
*/
BaseResponse<Boolean> updateMerchDiscountBySeller(MerchDiscount merchDiscount);
/**
* 给商户新增一个折扣信息配置
* @param merchDiscount 商户折扣信息
* @return 是否成功
*/
BaseResponse<MerchDiscount> addNewMerchDiscount(MerchDiscount merchDiscount);
}
......@@ -120,4 +120,13 @@ public interface IMerchantService extends IService<Merchant> {
* @return
*/
BaseResponse updateStore(StoreVo storeVo);
/**
* 验证敏感操作密码
* @param seller 商户id
* @param pwd 密码
* @return bool
*/
BaseResponse<Boolean> checkPwd(String seller,String pwd);
}
package cn.wise.sc.pay.business.merchant.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.pay.business.merchant.mapper.MerchDiscountMapper;
import cn.wise.sc.pay.business.merchant.service.IMerchDiscountService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.merchant.bean.MerchDiscount;
import cn.wise.sc.pay.domain.merchant.bean.Merchant;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @description:
* @author: qh
* @create: 2020-09-07 09:41
**/
@Service
public class MerchDiscountServiceImpl extends ServiceImpl<MerchDiscountMapper, MerchDiscount>
implements IMerchDiscountService {
@Override
public BaseResponse<MerchDiscount> getBySellerId(Long seller) {
if (seller == null || seller == 0L) {
return BaseResponse.error("seller不能为空!", MerchDiscount.class.getName());
}
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("seller_id", seller);
return BaseResponse.ok(this.getOne(queryWrapper));
}
@Override
public BaseResponse<Boolean> updateMerchDiscountBySeller(MerchDiscount merchDiscount) {
//判断折扣信息是否有效
String discountStr = merchDiscount.getDiscountStr();
if (StrUtil.isEmpty(discountStr)) {
return BaseResponse.error("折扣信息不能为空!", MerchDiscount.class.getName());
}
if (merchDiscount.getId() == null || merchDiscount.getId() <= 0 ||
merchDiscount.getSellerId() == null || merchDiscount.getSellerId() == 0) {
return BaseResponse.error("折扣信息不能为空!", MerchDiscount.class.getName());
}
try {
List<MerchDiscount.DiscountSetting> discountSettings =
JSON.parseArray(discountStr, MerchDiscount.DiscountSetting.class);
} catch (Exception ex) {
return BaseResponse.error("折扣信息配置格式不正确!",
MerchDiscount.class.getName());
}
boolean flag = this.updateById(merchDiscount);
if (flag) {
return BaseResponse.ok(true);
} else {
return BaseResponse.error("更新失败", Merchant.class.getName());
}
}
@Override
public BaseResponse<MerchDiscount> addNewMerchDiscount(MerchDiscount merchDiscount) {
//判断折扣信息是否有效
String discountStr = merchDiscount.getDiscountStr();
if (StrUtil.isEmpty(discountStr)) {
return BaseResponse.error("折扣信息不能为空!", MerchDiscount.class.getName());
}
if (merchDiscount.getSellerId() == null || merchDiscount.getSellerId() == 0) {
return BaseResponse.error("折扣信息不能为空!", MerchDiscount.class.getName());
}
try {
List<MerchDiscount.DiscountSetting> discountSettings =
JSON.parseArray(discountStr, MerchDiscount.DiscountSetting.class);
} catch (Exception ex) {
return BaseResponse.error("折扣信息配置格式不正确!",
MerchDiscount.class.getName());
}
//添加新的折扣信息
boolean save = this.save(merchDiscount);
if (save){
return BaseResponse.ok(merchDiscount);
}else {
return BaseResponse.error("添加失败!",MerchDiscount.class.getName());
}
}
}
......@@ -455,4 +455,19 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant>
}
return BaseResponse.okMsg("更新成功", this.getClass());
}
@Override
public BaseResponse<Boolean> checkPwd(String seller, String pwd) {
QueryWrapper query = new QueryWrapper();
query.eq("id", seller);
query.eq("sensitive_pwd", pwd);
int count = this.count(query);
if (count > 0) {
return BaseResponse.ok(true);
} else {
return BaseResponse.ok(false);
}
}
}
package cn.wise.sc.pay.domain.merchant.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 商户折扣表
* @author: qh
* @create: 2020-09-07 09:36
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("merchant_discount")
public class MerchDiscount extends Model<MerchDiscount> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 折扣
*/
private String discountStr;
/**
* 商户id
*/
private Long sellerId;
/**
* 折扣配置类
* id: 编号
* discount: 具体折扣
*/
@Data
public static class DiscountSetting{
private String id;
private Double discount;
}
}
......@@ -31,6 +31,11 @@ public class Merchant extends Model<Merchant> {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 敏感操作密码
*/
private String sensitivePwd;
/**
* 奥索商户账号
*/
......
package cn.wise.sc.pay.api.order.service;
import cn.wise.sc.pay.api.order.service.impl.ZHPayMerServiceImplHystrix;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.order.model.MerchantPayPro;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @description:
* @author: qh
* @create: 2020-09-24 12:42
**/
@FeignClient(value = "saas-v1-order", path = "/pay/setting", fallback = ZHPayMerServiceImplHystrix.class)
public interface IZHPayMerService {
@PostMapping("/create")
BaseResponse<Boolean> create(@RequestBody MerchantPayPro merchantPayPro);
@DeleteMapping("/{id}")
BaseResponse<Boolean> delete(@PathVariable("id") Long id);
@GetMapping("/{sellerId}")
BaseResponse<MerchantPayPro> getBySeller(@PathVariable("sellerId") Long sellerId);
}
package cn.wise.sc.pay.api.order.service;
import cn.wise.sc.pay.api.order.service.impl.ZHPaymentServiceImplHystrix;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* @description: 招行聚合支付 服务接口
* 详细参考 : /wiki/招商银行商户聚合支付接口V2.1.doc
* @author: qh
* @create: 2020-01-14 09:30
**/
@FeignClient(value = "saas-v1-order", path = "/sms", fallback = ZHPaymentServiceImplHystrix.class)
public interface IZHPaymentService {
/**
* 小程序获取openid
*
* @param code
* @return
*/
@RequestMapping(value = "/getOpenid", method = RequestMethod.GET)
ResponseEntity<Map<String, Object>> getUserOpenId(String code);
/**
* 微信统一下单
*
* @param request 请求报文 用于获取主机ip
* @param orderId 订单号
* @param openId openId
* @param body
* @param txnAmt 金额 分为单位
* @return
*/
@PostMapping("/unifiedOrder")
BaseResponse wxUnifiedOrder(HttpServletRequest request, @RequestParam("orderId") String orderId,
@RequestParam("openId") String openId, @RequestParam("body") String body,
@RequestParam("txnAmt") String txnAmt, @RequestParam("sellerId") String sellerId);
/**
* 支付主动查询
*
* @param cmbOrderId 招行聚合订单号 (订单号二选一,二者都传默认使用聚合订单号)
* @param orderId 订单号
* @return
*/
@PostMapping("/payResultQuery")
BaseResponse payResultQuery(@RequestParam("cmbOrderId") String cmbOrderId,
@RequestParam("orderId") String orderId,
@RequestParam("sellerId") String sellerId);
/**
* 支付结果通知
*
* @param cmbOrderId 招行聚合订单号 (订单号二选一,二者都传默认使用聚合订单号)
* @param orderId 订单号
* @param txnAmt 金额
* @param dscAmt 优惠金额
* @param payType 支付类型
* @param txnTime 时间
* @return
*/
@PostMapping("payResultNotice")
BaseResponse payResultNotice(@RequestParam("cmbOrderId") String cmbOrderId, @RequestParam("orderId") String orderId,
@RequestParam("txnAmt") String txnAmt,
@RequestParam("dscAmt") String dscAmt, @RequestParam("payType") String payType,
@RequestParam("txnTime") String txnTime,
@RequestParam("sellerId") String sellerId);
/**
* 退款主动查询
*
* @param orderId 订单号
* @param origCmbOrderId 招行聚合订单号 (订单号二选一,二者都传默认使用聚合订单号)
* @return
*/
@PostMapping("payRefundQuery")
BaseResponse payRefundQuery(@RequestParam("orderId") String orderId,
@RequestParam("origCmbOrderId") String origCmbOrderId,
@RequestParam("sellerId") String sellerId);
/**
* 申请退款
*
* @param orderId 退款订单号
* @param origOrderId 支付订单号
* @param txnAmt 金额
* @param refundAmt 退款金额
* @param refundReason 原因
* @return
*/
@PostMapping("applyForRefund")
BaseResponse applyForRefund(@RequestParam("orderId") String orderId,
@RequestParam("origOrderId") String origOrderId,
@RequestParam("txnAmt") String txnAmt, @RequestParam("refundAmt") String refundAmt,
@RequestParam("refundReason") String refundReason,
@RequestParam("sellerId") String sellerId);
/**
* 退款通知
*
* @param orderId 订单号
* @param cmbOrderId 招行聚合订单号 (订单号二选一,二者都传默认使用聚合订单号)
* @param refundAmt 退款金额
* @return
*/
@PostMapping("payRefundNotice")
BaseResponse payRefundNotice(@RequestParam("orderId") String orderId, @RequestParam("cmbOrderId") String cmbOrderId,
@RequestParam("refundAmt") String refundAmt, @RequestParam("refundDscAmt") String refundDscAmt,
@RequestParam("couponInfo") String couponInfo, @RequestParam("payType") String payType,
@RequestParam("txnTime") String txnTime, @RequestParam("endDate") String endDate,
@RequestParam("endTime") String endTime, @RequestParam("mchReserved") String mchReserved);
/**
* 关闭订单
*
* @param origOrderId 订单
* @param origCmbOrderId 招行聚合订单号 (订单号二选一,二者都传默认使用聚合订单号)
* @return
*/
@PostMapping("closeOrder")
BaseResponse closeOrder(@RequestParam("origOrderId") String origOrderId,
@RequestParam("origCmbOrderId") String origCmbOrderId,
@RequestParam("sellerId") String sellerId);
/**
* 获取对账地址
*
* @param billDate 下载对账单的日期,格式:20180803
* @return
*/
@PostMapping("getBillUrl")
BaseResponse getBillUrl(@RequestParam("billDate") String billDate, @RequestParam("sellerId") String sellerId);
/**
* 设置密钥
*
* @param platformId 招行分配的平台或技术服务商的编号
* @param digEvpEncMth 数字信封加密算法 01:RSA2
* @param digEvp 数字信封
* @param encryptMethod 加密方法 02:AES
* @param encryptInfo encryptInfo AES256加密数据包
* @param keyTpye keyTpye RSA/SM2/MD5等,目前只支持RSA
* @param keyLen keyLen 1024/2048/256,目前只支持2048长度的公钥
* @param mchKey mchKey 商户公钥明文
* @param updateUrl 保留使用
* @return
*/
@PostMapping("setSecretKey")
BaseResponse setSecretKey(@RequestParam("platformId") String platformId, @RequestParam("digEvpEncMth") String digEvpEncMth,
@RequestParam("digEvp") String digEvp, @RequestParam("encryptMethod") String encryptMethod,
@RequestParam("encryptInfo") String encryptInfo, @RequestParam("keyTpye") String keyTpye,
@RequestParam("keyLen") String keyLen, @RequestParam("mchKey") String mchKey,
@RequestParam("updateUrl") String updateUrl);
/**
* 发起服务窗口支付
*
* @param deviceInfo 终端设备号
* @param orderId 商户端生成,要求此订单号在整个商户下唯一
* @param tradeScene OFFLINE:线下场景(OFFLINE合同)
* INSURANCE:保险
* CHARITY:公益
* @param body 商品描述
* @param mchReserved 商户保留域
* @param timeoutExpress 支付有效时间
* @param notifyUrl 交易通知地址
* @param txnAmt 交易金额
* @param currencyCode 交易币种
* @param disablePayChannels 限制支付渠道
* @param buyerLogonId 去买家支付宝账号
* @param buyerId 买家支付宝用户ID
* @param identity 实名支付信息
* @param policyNo 保单单号
* @param region 地区码
* @return
*/
@PostMapping("servicePay")
BaseResponse servicePay(@RequestParam("deviceInfo") String deviceInfo, @RequestParam("orderId") String orderId,
@RequestParam("tradeScene") String tradeScene, @RequestParam("body") String body,
@RequestParam("mchReserved") String mchReserved, @RequestParam("timeoutExpress") String timeoutExpress,
@RequestParam("notifyUrl") String notifyUrl, @RequestParam("txnAmt") String txnAmt,
@RequestParam("currencyCode") String currencyCode, @RequestParam("disablePayChannels") String disablePayChannels,
@RequestParam("buyerLogonId") String buyerLogonId, @RequestParam("buyerId") String buyerId,
@RequestParam("identity") String identity, @RequestParam("policyNo") String policyNo,
@RequestParam("region") String region,
@RequestParam("sellerId") String sellerId);
}
package cn.wise.sc.pay.api.order.service.impl;
import cn.wise.sc.pay.api.order.service.IZHPayMerService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.domain.order.model.MerchantPayPro;
import org.springframework.stereotype.Component;
/**
* @description:
* @author: qh
* @create: 2020-09-24 12:42
**/
@Component
public class ZHPayMerServiceImplHystrix implements IZHPayMerService {
@Override
public BaseResponse<Boolean> create(MerchantPayPro merchantPayPro) {
return BaseResponse.error("添加失败!请检查参数!", this.getClass().getName());
}
@Override
public BaseResponse<Boolean> delete(Long id) {
return BaseResponse.error("删除失败!", this.getClass().getName());
}
@Override
public BaseResponse<MerchantPayPro> getBySeller(Long sellerId) {
return BaseResponse.error("没找到!",this.getClass().getName());
}
}
package cn.wise.sc.pay.api.order.service.impl;
import cn.wise.sc.pay.api.order.service.IZHPaymentService;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* @description: 招行聚合支付 熔断器
* @author: qh
* @create: 2020-01-14 10:32
**/
@Component("orderIZHPaymentService")
public class ZHPaymentServiceImplHystrix implements IZHPaymentService {
@Override
public ResponseEntity<Map<String, Object>> getUserOpenId(String code) {
return null;
}
@Override
public BaseResponse wxUnifiedOrder(HttpServletRequest request, String orderId,
String openId, String body, String txnAmt,
String sellerId) {
error();
return null;
}
@Override
public BaseResponse payResultQuery(String cmbOrderId, String orderId, String sellerId) {
return null;
}
@Override
public BaseResponse payResultNotice(String cmbOrderId, String orderId, String txnAmt,
String dscAmt, String payType, String txnTime,
String sellerId) {
return null;
}
@Override
public BaseResponse payRefundQuery(String orderId, String origCmbOrderId, String sellerId) {
return BaseResponse.error("失败!", this.getClass().getName());
}
@Override
public BaseResponse applyForRefund(String orderId, String origOrderId,
String txnAmt, String refundAmt,
String refundReason, String sellerId) {
return null;
}
@Override
public BaseResponse payRefundNotice(String orderId, String cmbOrderId, String refundAmt, String refundDscAmt, String couponInfo, String payType, String txnTime, String endDate, String endTime, String mchReserved) {
return null;
}
@Override
public BaseResponse closeOrder(String origOrderId, String origCmbOrderId, String sellerId) {
return null;
}
@Override
public BaseResponse getBillUrl(String billDate, String sellerId) {
return null;
}
@Override
public BaseResponse setSecretKey(String platformId, String digEvpEncMth, String digEvp, String encryptMethod, String encryptInfo, String keyTpye, String keyLen, String mchKey, String updateUrl) {
return null;
}
@Override
public BaseResponse servicePay(String deviceInfo, String orderId, String tradeScene,
String body, String mchReserved, String timeoutExpress,
String notifyUrl, String txnAmt, String currencyCode,
String disablePayChannels, String buyerLogonId,
String buyerId, String identity, String policyNo, String region,
String sellerId
) {
error();
return null;
}
private void error() {
throw new RuntimeException("支付服务异常");
}
}
......@@ -11,18 +11,19 @@
<artifactId>order-business</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>common-redis</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
......@@ -43,10 +44,6 @@
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-generator</artifactId>-->
<!-- </dependency>-->
<!--模板引擎 -->
<dependency>
<groupId>org.apache.velocity</groupId>
......@@ -61,12 +58,6 @@
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!--&lt;!&ndash;dubbo&ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-dubbo</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
......@@ -83,7 +74,6 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<!--easy excel-->
<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
<dependency>
......@@ -96,7 +86,6 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
......@@ -114,6 +103,36 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.8.10.ALL</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>merchant-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>payment-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>laas-goods</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.wisenergy.sc.card</groupId>
<artifactId>payment-ali</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<!--本地启动-->
......@@ -148,7 +167,14 @@
<includes>
<include>*</include>
</includes>
<!--开启过滤,用指定的参数替换directory下的文件中的参数-->
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/production</directory>
<includes>
<include>*</include>
</includes>
<targetPath>/production</targetPath>
<filtering>true</filtering>
</resource>
<resource>
......
......@@ -20,7 +20,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@MapperScan(basePackageClasses = XpenseTrackerMapper.class)
public class OrderApplication {
public static void main(String[] args) {
SpringApplication.run(OrderApplication.class, args);
}
}
package cn.wise.sc.pay.business.order.ali;
import cn.hutool.core.util.StrUtil;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.CertAlipayRequest;
import com.alipay.api.DefaultAlipayClient;
import java.io.Serializable;
/**
* <p>IJPay 让支付触手可及,封装了微信支付、支付宝支付、银联支付常用的支付方式以及各种常用的接口。</p>
*
* <p>不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。 </p>
*
* <p>IJPay 交流群: 723992875</p>
*
* <p>Node.js 版: https://gitee.com/javen205/TNW</p>
*
* <p>支付宝支付配置</p>
*
* @author Javen
*/
public class AliPayApiConfig implements Serializable {
private static final long serialVersionUID = -4736760736935998953L;
private String privateKey;
private String aliPayPublicKey;
private String appId;
private String serviceUrl;
private String charset;
private String signType;
private String format;
private String appCertPath;
private String aliPayCertPath;
private String aliPayRootCertPath;
private AlipayClient alipayClient;
private AliPayApiConfig() {
}
public static AliPayApiConfig builder() {
return new AliPayApiConfig();
}
public AliPayApiConfig build() {
this.alipayClient = new DefaultAlipayClient(getServiceUrl(), getAppId(), getPrivateKey(), getFormat(),
getCharset(), getAliPayPublicKey(), getSignType());
return this;
}
public AliPayApiConfig buildByCert() throws AlipayApiException {
return build(getAppCertPath(), getAliPayCertPath(), getAliPayRootCertPath());
}
/**
* @param appCertPath 应用公钥证书路径
* @param aliPayCertPath 支付宝公钥证书文件路径
* @param aliPayRootCertPath 支付宝CA根证书文件路径
* @return {@link AliPayApiConfig} 支付宝支付配置
* @throws AlipayApiException
*/
public AliPayApiConfig build(String appCertPath, String aliPayCertPath, String aliPayRootCertPath) throws AlipayApiException {
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
certAlipayRequest.setServerUrl(getServiceUrl());
certAlipayRequest.setAppId(getAppId());
certAlipayRequest.setPrivateKey(getPrivateKey());
certAlipayRequest.setFormat(getFormat());
certAlipayRequest.setCharset(getCharset());
certAlipayRequest.setSignType(getSignType());
certAlipayRequest.setCertPath(appCertPath);
certAlipayRequest.setAlipayPublicCertPath(aliPayCertPath);
certAlipayRequest.setRootCertPath(aliPayRootCertPath);
this.alipayClient = new DefaultAlipayClient(certAlipayRequest);
return this;
}
public String getPrivateKey() {
if (StrUtil.isBlank(privateKey)) {
throw new IllegalStateException("privateKey 未被赋值");
}
return privateKey;
}
public AliPayApiConfig setPrivateKey(String privateKey) {
if (StrUtil.isEmpty(privateKey)) {
throw new IllegalArgumentException("privateKey 值不能为 null");
}
this.privateKey = privateKey;
return this;
}
public String getAliPayPublicKey() {
if (StrUtil.isEmpty(aliPayPublicKey)) {
throw new IllegalStateException("aliPayPublicKey 未被赋值");
}
return aliPayPublicKey;
}
public AliPayApiConfig setAliPayPublicKey(String aliPayPublicKey) {
if (StrUtil.isEmpty(aliPayPublicKey)) {
throw new IllegalArgumentException("aliPayPublicKey 值不能为 null");
}
this.aliPayPublicKey = aliPayPublicKey;
return this;
}
public String getAppId() {
if (StrUtil.isEmpty(appId)) {
throw new IllegalStateException("appId 未被赋值");
}
return appId;
}
public AliPayApiConfig setAppId(String appId) {
if (StrUtil.isEmpty(appId)) {
throw new IllegalArgumentException("appId 值不能为 null");
}
this.appId = appId;
return this;
}
public String getServiceUrl() {
if (StrUtil.isEmpty(serviceUrl)) {
throw new IllegalStateException("serviceUrl 未被赋值");
}
return serviceUrl;
}
public AliPayApiConfig setServiceUrl(String serviceUrl) {
if (StrUtil.isEmpty(serviceUrl)) {
serviceUrl = "https://openapi.alipay.com/gateway.do";
}
this.serviceUrl = serviceUrl;
return this;
}
public String getCharset() {
if (StrUtil.isEmpty(charset)) {
charset = "UTF-8";
}
return charset;
}
public AliPayApiConfig setCharset(String charset) {
if (StrUtil.isEmpty(charset)) {
charset = "UTF-8";
}
this.charset = charset;
return this;
}
public String getSignType() {
if (StrUtil.isEmpty(signType)) {
signType = "RSA2";
}
return signType;
}
public AliPayApiConfig setSignType(String signType) {
if (StrUtil.isEmpty(signType)) {
signType = "RSA2";
}
this.signType = signType;
return this;
}
public String getFormat() {
if (StrUtil.isEmpty(format)) {
format = "json";
}
return format;
}
public String getAppCertPath() {
return appCertPath;
}
public AliPayApiConfig setAppCertPath(String appCertPath) {
this.appCertPath = appCertPath;
return this;
}
public String getAliPayCertPath() {
return aliPayCertPath;
}
public AliPayApiConfig setAliPayCertPath(String aliPayCertPath) {
this.aliPayCertPath = aliPayCertPath;
return this;
}
public String getAliPayRootCertPath() {
return aliPayRootCertPath;
}
public AliPayApiConfig setAliPayRootCertPath(String aliPayRootCertPath) {
this.aliPayRootCertPath = aliPayRootCertPath;
return this;
}
public AlipayClient getAliPayClient() {
if (alipayClient == null) {
throw new IllegalStateException("aliPayClient 未被初始化");
}
return alipayClient;
}
}
\ No newline at end of file
package cn.wise.sc.pay.business.order.ali;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* <p>IJPay 让支付触手可及,封装了微信支付、支付宝支付、银联支付常用的支付方式以及各种常用的接口。</p>
*
* <p>不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。 </p>
*
* <p>IJPay 交流群: 723992875</p>
*
* <p>Node.js 版: https://gitee.com/javen205/TNW</p>
*
* @author Javen
*/
public class AliPayApiConfigKit {
private static final ThreadLocal<String> TL = new ThreadLocal<String>();
private static final Map<String, AliPayApiConfig> CFG_MAP = new ConcurrentHashMap<String, AliPayApiConfig>();
private static final String DEFAULT_CFG_KEY = "_default_key_";
/**
* <p>向缓存中设置 AliPayApiConfig </p>
* <p>每个 appId 只需添加一次,相同 appId 将被覆盖</p>
*
* @param aliPayApiConfig 支付宝支付配置
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig putApiConfig(AliPayApiConfig aliPayApiConfig) {
if (CFG_MAP.size() == 0) {
CFG_MAP.put(DEFAULT_CFG_KEY, aliPayApiConfig);
}
return CFG_MAP.put(aliPayApiConfig.getAppId(), aliPayApiConfig);
}
/**
* 向当前线程中设置 {@link AliPayApiConfig}
*
* @param aliPayApiConfig {@link AliPayApiConfig} 支付宝配置对象
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig setThreadLocalAliPayApiConfig(AliPayApiConfig aliPayApiConfig) {
if (StrUtil.isNotEmpty(aliPayApiConfig.getAppId())){
setThreadLocalAppId(aliPayApiConfig.getAppId());
}
return putApiConfig(aliPayApiConfig);
}
/**
* 通过 AliPayApiConfig 移除支付配置
*
* @param aliPayApiConfig {@link AliPayApiConfig} 支付宝配置对象
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig removeApiConfig(AliPayApiConfig aliPayApiConfig) {
return removeApiConfig(aliPayApiConfig.getAppId());
}
/**
* 通过 appId 移除支付配置
*
* @param appId 支付宝应用编号
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig removeApiConfig(String appId) {
return CFG_MAP.remove(appId);
}
/**
* 向当前线程中设置 appId
*
* @param appId 支付宝应用编号
*/
public static void setThreadLocalAppId(String appId) {
if (StrUtil.isEmpty(appId)) {
appId = CFG_MAP.get(DEFAULT_CFG_KEY).getAppId();
}
TL.set(appId);
}
/**
* 移除当前线程中的 appId
*/
public static void removeThreadLocalAppId() {
TL.remove();
}
/**
* 获取当前线程中的 appId
*
* @return 支付宝应用编号 appId
*/
public static String getAppId() {
String appId = TL.get();
if (StrUtil.isEmpty(appId)) {
appId = CFG_MAP.get(DEFAULT_CFG_KEY).getAppId();
}
return appId;
}
/**
* 获取当前线程中的 AliPayApiConfig
*
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig getAliPayApiConfig() {
String appId = getAppId();
return getApiConfig(appId);
}
/**
* 通过 appId 获取 AliPayApiConfig
*
* @param appId 支付宝应用编号
* @return {@link AliPayApiConfig}
*/
public static AliPayApiConfig getApiConfig(String appId) {
AliPayApiConfig cfg = CFG_MAP.get(appId);
if (cfg == null) {
throw new IllegalStateException("需事先调用 AliPayApiConfigKit.putApiConfig(aliPayApiConfig) 将 appId对应的 aliPayApiConfig 对象存入,才可以使用 AliPayApiConfigKit.getAliPayApiConfig() 的系列方法");
}
return cfg;
}
}
\ No newline at end of file
package cn.wise.sc.pay.business.order.ali;
import cn.hutool.crypto.SecureUtil;
import cn.wise.sc.payment.core.enums.SignType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//import cn.wise.sc.payment.ali.enums.SignType;
/**
* <p>IJPay 让支付触手可及,封装了微信支付、支付宝支付、银联支付常用的支付方式以及各种常用的接口。</p>
*
* <p>不依赖任何第三方 mvc 框架,仅仅作为工具使用简单快速完成支付模块的开发,可轻松嵌入到任何系统里。 </p>
*
* <p>IJPay 交流群: 723992875</p>
*
* <p>Node.js 版: https://gitee.com/javen205/TNW</p>
*
* @author Javen
*/
public class AliPayCore {
/**
* 生成签名结果
*
* @param params 要签名的数组
* @param key 签名密钥
* @param signType 签名类型
* @return 签名结果字符串
*/
public static String buildRequestMySign(Map<String, String> params, String key, String signType) {
// 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
String preStr = createLinkString(params);
if (SignType.MD5.getType().equals(signType)) {
return SecureUtil.md5(preStr.concat(key));
}
return null;
}
/**
* 生成要请求给支付宝的参数数组
*
* @param params 请求前的参数数组
* @param key 商户的私钥
* @param signType 签名类型
* @return 要请求的参数数组
*/
public static Map<String, String> buildRequestPara(Map<String, String> params, String key, String signType) {
// 除去数组中的空值和签名参数
Map<String, String> tempMap = paraFilter(params);
// 生成签名结果
String mySign = buildRequestMySign(params, key, signType);
// 签名结果与签名方式加入请求提交参数组中
tempMap.put("sign", mySign);
tempMap.put("sign_type", signType);
return tempMap;
}
/**
* 除去数组中的空值和签名参数
*
* @param sArray 签名参数组
* @return 去掉空值与签名参数后的新签名参数组
*/
public static Map<String, String> paraFilter(Map<String, String> sArray) {
Map<String, String> result = new HashMap<String, String>(sArray.size());
if (sArray == null || sArray.size() <= 0) {
return result;
}
for (String key : sArray.keySet()) {
String value = sArray.get(key);
if (value == null || "".equals(value) || "sign".equalsIgnoreCase(key)
|| "sign_type".equalsIgnoreCase(key)) {
continue;
}
result.put(key, value);
}
return result;
}
/**
* 把数组所有元素排序
*
* @param params 需要排序并参与字符拼接的参数组
* @return 拼接后字符串
*/
public static String createLinkString(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
StringBuffer content = new StringBuffer();
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
// 拼接时,不包括最后一个&字符
if (i == keys.size() - 1) {
content.append(key + "=" + value);
} else {
content.append(key + "=" + value + "&");
}
}
return content.toString();
}
}
\ No newline at end of file
//package cn.wise.sc.pay.business.order.config;
//
//import cn.hutool.json.JSONUtil;
//import cn.wise.sc.pay.common.core.model.TransactionMessage;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Component;
//import java.io.IOException;
//
///**
// * @description:
// * @author: qh
// * @create: 2020-09-13 10:39
// **/
//@Slf4j
//@RabbitListener(queues = RabbitConsts.DIRECT_MODE_QUEUE_ONE)
//@Component
//public class DirectQueueOneHandler {
// /**
// * 如果 spring.rabbitmq.listener.direct.acknowledge-mode: auto,则可以用这个方式,会自动ack
// */
// // @RabbitHandler
// public void directHandlerAutoAck(TransactionMessage message) {
// log.info("直接队列处理器,接收消息:{}", JSONUtil.toJsonStr(message));
// }
//
// @RabbitHandler
// public void directHandlerManualAck(TransactionMessage messageStruct, Message message, Channel channel) {
// // 如果手动ACK,消息会被监听消费,但是消息在队列中依旧存在,如果 未配置 acknowledge-mode 默认是会在消费完毕后自动ACK掉
// final long deliveryTag = message.getMessageProperties().getDeliveryTag();
// try {
// log.info("直接队列1,手动ACK,接收消息:{}", JSONUtil.toJsonStr(messageStruct));
// // 通知 MQ 消息已被成功消费,可以ACK了
// channel.basicAck(deliveryTag, false);
// } catch (IOException e) {
// try {
// // 处理失败,重新压入MQ
// channel.basicRecover();
// } catch (IOException e1) {
// e1.printStackTrace();
// }
// }
// }
//}
//package cn.wise.sc.pay.business.order.config;
//
//import com.google.common.collect.Maps;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.BindingBuilder;
//import org.springframework.amqp.core.CustomExchange;
//import org.springframework.amqp.core.FanoutExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.core.TopicExchange;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import java.util.Map;
//
///**
// * @description:
// * @author: qh
// * @create: 2020-09-12 11:32
// **/
//@Slf4j
//@Configuration
//public class MqConfigure {
//
// @Bean
// public RabbitTemplate rabbitTemplate(CachingConnectionFactory connectionFactory) {
// connectionFactory.setPublisherConfirms(true);
// connectionFactory.setPublisherReturns(true);
// RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
// rabbitTemplate.setMandatory(true);
// rabbitTemplate.setConfirmCallback((correlationData, ack, cause) -> log.info("消息发送成功:correlationData({}),ack({}),cause({})", correlationData, ack, cause));
// rabbitTemplate.setReturnCallback((message, replyCode, replyText, exchange, routingKey) -> log.info("消息丢失:exchange({}),route({}),replyCode({}),replyText({}),message:{}", exchange, routingKey, replyCode, replyText, message));
// return rabbitTemplate;
// }
//
//
// /**
// * 直接模式队列1
// */
// @Bean
// public Queue directOneQueue() {
// return new Queue(RabbitConsts.DIRECT_MODE_QUEUE_ONE);
// }
//
// /**
// * 队列2
// */
// @Bean
// public Queue queueTwo() {
// return new Queue(RabbitConsts.QUEUE_TWO);
// }
//
// /**
// * 队列3
// */
// @Bean
// public Queue queueThree() {
// return new Queue(RabbitConsts.QUEUE_THREE);
// }
//
// /**
// * 分列模式队列
// */
// @Bean
// public FanoutExchange fanoutExchange() {
// return new FanoutExchange(RabbitConsts.FANOUT_MODE_QUEUE);
// }
//
// /**
// * 分列模式绑定队列1
// *
// * @param directOneQueue 绑定队列1
// * @param fanoutExchange 分列模式交换器
// */
// @Bean
// public Binding fanoutBinding1(Queue directOneQueue, FanoutExchange fanoutExchange) {
// return BindingBuilder.bind(directOneQueue).to(fanoutExchange);
// }
//
// /**
// * 分列模式绑定队列2
// *
// * @param queueTwo 绑定队列2
// * @param fanoutExchange 分列模式交换器
// */
// @Bean
// public Binding fanoutBinding2(Queue queueTwo, FanoutExchange fanoutExchange) {
// return BindingBuilder.bind(queueTwo).to(fanoutExchange);
// }
//
// /**
// * 主题模式队列
// * <li>路由格式必须以 . 分隔,比如 user.email 或者 user.aaa.email</li>
// * <li>通配符 * ,代表一个占位符,或者说一个单词,比如路由为 user.*,那么 user.email 可以匹配,但是 user.aaa.email 就匹配不了</li>
// * <li>通配符 # ,代表一个或多个占位符,或者说一个或多个单词,比如路由为 user.#,那么 user.email 可以匹配,user.aaa.email 也可以匹配</li>
// */
// @Bean
// public TopicExchange topicExchange() {
// return new TopicExchange(RabbitConsts.TOPIC_MODE_QUEUE);
// }
//
//
// /**
// * 主题模式绑定分列模式
// *
// * @param fanoutExchange 分列模式交换器
// * @param topicExchange 主题模式交换器
// */
// @Bean
// public Binding topicBinding1(FanoutExchange fanoutExchange, TopicExchange topicExchange) {
// return BindingBuilder.bind(fanoutExchange).to(topicExchange).with(RabbitConsts.TOPIC_ROUTING_KEY_ONE);
// }
//
// /**
// * 主题模式绑定队列2
// *
// * @param queueTwo 队列2
// * @param topicExchange 主题模式交换器
// */
// @Bean
// public Binding topicBinding2(Queue queueTwo, TopicExchange topicExchange) {
// return BindingBuilder.bind(queueTwo).to(topicExchange).with(RabbitConsts.TOPIC_ROUTING_KEY_TWO);
// }
//
// /**
// * 主题模式绑定队列3
// *
// * @param queueThree 队列3
// * @param topicExchange 主题模式交换器
// */
// @Bean
// public Binding topicBinding3(Queue queueThree, TopicExchange topicExchange) {
// return BindingBuilder.bind(queueThree).to(topicExchange).with(RabbitConsts.TOPIC_ROUTING_KEY_THREE);
// }
//
// /**
// * 延迟队列
// */
// @Bean
// public Queue delayQueue() {
// return new Queue(RabbitConsts.DELAY_QUEUE, true);
// }
//
// /**
// * 延迟队列交换器, x-delayed-type 和 x-delayed-message 固定
// */
// @Bean
// public CustomExchange delayExchange() {
// Map<String, Object> args = Maps.newHashMap();
// args.put("x-delayed-type", "direct");
// return new CustomExchange(RabbitConsts.DELAY_MODE_QUEUE, "x-delayed-message", true, false, args);
// }
//
// /**
// * 延迟队列绑定自定义交换器
// *
// * @param delayQueue 队列
// * @param delayExchange 延迟交换器
// */
// @Bean
// public Binding delayBinding(Queue delayQueue, CustomExchange delayExchange) {
// return BindingBuilder.bind(delayQueue).to(delayExchange).with(RabbitConsts.DELAY_QUEUE).noargs();
// }
//}
\ No newline at end of file
package cn.wise.sc.pay.business.order.config;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfig {
@Bean
public Queue helloQueue() {
return new Queue("hello"); //配置一个名称为"hello"的Queue队列
}
@Bean(name = "connectionFactory")
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setUsername("admin");
connectionFactory.setPassword("admin");
connectionFactory.setVirtualHost("/");
connectionFactory.setPublisherConfirms(true);
//该方法配置多个host,在当前连接host down掉的时候会自动去重连后面的host
connectionFactory.setAddresses("81.68.92.175");
return connectionFactory;
}
}
\ No newline at end of file
//package cn.wise.sc.pay.business.order.config;
//
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class RabbitConfig {
//
// @Bean
// public Queue helloQueue() {
// return new Queue("hello"); //配置一个名称为"hello"的Queue队列
// }
//
// @Bean(name = "connectionFactory")
// public ConnectionFactory connectionFactory() {
// CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
//
// connectionFactory.setUsername("admin");
// connectionFactory.setPassword("admin");
// connectionFactory.setVirtualHost("/");
// connectionFactory.setPublisherConfirms(true);
//
// //该方法配置多个host,在当前连接host down掉的时候会自动去重连后面的host
// connectionFactory.setAddresses("81.68.92.175");
// return connectionFactory;
// }
//
//}
\ No newline at end of file
package cn.wise.sc.pay.business.order.config;
/**
* @description:
* @author: qh
* @create: 2020-09-13 10:38
**/
public interface RabbitConsts {
/**
* 直接模式1
*/
String DIRECT_MODE_QUEUE_ONE = "queue.direct.1";
/**
* 队列2
*/
String QUEUE_TWO = "queue.2";
/**
* 队列3
*/
String QUEUE_THREE = "3.queue";
/**
* 分列模式
*/
String FANOUT_MODE_QUEUE = "fanout.mode";
/**
* 主题模式
*/
String TOPIC_MODE_QUEUE = "topic.mode";
/**
* 路由1
*/
String TOPIC_ROUTING_KEY_ONE = "queue.#";
/**
* 路由2
*/
String TOPIC_ROUTING_KEY_TWO = "*.queue";
/**
* 路由3
*/
String TOPIC_ROUTING_KEY_THREE = "3.queue";
/**
* 延迟队列
*/
String DELAY_QUEUE = "delay.queue";
/**
* 延迟队列交换器
*/
String DELAY_MODE_QUEUE = "delay.mode";
}
package cn.wise.sc.pay.business.order.configure;
import javax.servlet.http.HttpServletRequest;
import java.security.MessageDigest;
import java.util.Arrays;
/**
* @class WX_Util 类;
*/
public class WX_Util {
//验证服务器地址
public static String check_Url(HttpServletRequest request,String token){
//获取参数配置
String signature = request.getParameter("signature");
//获取时间托
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
//获取echostr 字符
String echostr = request.getParameter("echostr");
//获取token 此token跟需跟微信公众号的token一致;
String str = "";
// try ---- catch 捕捉异常
try {
//判断是否为空
if (null != signature) {
//声明一个存储数据字符数组
String[] ArrTmp = { token, timestamp, nonce };
Arrays.sort(ArrTmp);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ArrTmp.length; i++) {
sb.append(ArrTmp[i]);
}
//获取消息对象
MessageDigest md = MessageDigest.getInstance("SHA-1");
//声明一个字节流数组;
byte[] bytes = md.digest(new String(sb).getBytes());
//声明一个字符流
StringBuffer buf = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
if (((int) bytes[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) bytes[i] & 0xff, 16));
}
if (signature.equals(buf.toString())) {
str = echostr;
}
}
} catch (Exception e) {
e.printStackTrace();
}
//返回消息
return str;
}
}
\ No newline at end of file
package cn.wise.sc.pay.business.order.controller;
import cn.wise.sc.pay.business.order.ali.AliPayApiConfig;
public abstract class AbstractAliPayApiController {
/**
* 获取支付宝配置
* @return {@link AliPayApiConfig} 支付宝配置
*/
public abstract AliPayApiConfig getApiConfig();
}
package cn.wise.sc.pay.business.order.controller;
import cn.wise.sc.pay.business.order.ali.AliPayApiConfig;
import cn.wise.sc.pay.business.order.ali.AliPayApiConfigKit;
import cn.wise.sc.pay.business.order.model.AliPayBean;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipayEncrypt;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController
@CrossOrigin
@RequestMapping("/alipay")
public class AliController extends AbstractAliPayApiController{
private static final Logger log = LoggerFactory.getLogger(AliController.class);
@Autowired
private AliPayBean aliPayBean;
@Override
public AliPayApiConfig getApiConfig() {
AliPayApiConfig aliPayApiConfig;
try {
AliPayApiConfigKit.setThreadLocalAppId(aliPayBean.getAppId());
aliPayApiConfig = AliPayApiConfigKit.getApiConfig(aliPayBean.getAppId());
} catch (Exception e) {
aliPayApiConfig = AliPayApiConfig.builder()
.setAppId(aliPayBean.getAppId())
.setAliPayPublicKey(aliPayBean.getPublicKey())
.setCharset("UTF-8")
.setPrivateKey(aliPayBean.getPrivateKey())
.setServiceUrl("https://openapi.alipay.com/gateway.do?")
.setSignType("RSA2")
.build();
AliPayApiConfigKit.setThreadLocalAppId(aliPayBean.getAppId()); // 2.1.2 之后的版本,可以不用单独设置
AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig);
}
return aliPayApiConfig;
}
/**
* 应用授权回调
*/
@RequestMapping(value = "/getBuyerId")
@ResponseBody
public BaseResponse getBuyerId(@RequestParam("auth_code") String authCode) {
try {
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(authCode);
request.setGrantType("authorization_code");
AliPayApiConfig config = getApiConfig();
AlipayClient client = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
config.getAppId(),
config.getPrivateKey(),
"json",
"utf-8",
config.getAliPayPublicKey(),
"RSA2");
AlipaySystemOauthTokenResponse oauthTokenResponse = client.execute(request);
return BaseResponse.ok(oauthTokenResponse.getUserId());
} catch (Exception e) {
log.error(e.getMessage());
}
return BaseResponse.error("服务异常",AliController.class);
}
@PostMapping("/checkRsa")
public BaseResponse rsaCheck(String param){
//1. 获取验签和解密所需要的参数
Map<String, String> openapiResult = JSON.parseObject(param,
new TypeReference<Map<String, String>>() {
}, Feature.OrderedField);
String signType = "RSA2";
String charset = "UTF-8";
String encryptType = "AES";
String sign = openapiResult.get("sign");
String content = openapiResult.get("response");
//如果密文的
boolean isDataEncrypted = !content.startsWith("{");
boolean signCheckPass = false;
//2. 验签
String signContent = content;
AliPayApiConfig config = getApiConfig();
String signVeriKey = config.getAliPayPublicKey();
String decryptKey = config.getPrivateKey();
//如果是加密的报文则需要在密文的前后添加双引号
if (isDataEncrypted) {
signContent = "\"" + signContent + "\"";
}
try {
signCheckPass = AlipaySignature.rsaCheck(signContent, sign, signVeriKey, charset, signType);
} catch (AlipayApiException e) {
log.error("验签失败",AliPayApiConfig.class);
}
if(!signCheckPass) {
return BaseResponse.error("验签失败",AliPayApiConfig.class.getName());
}
String plainData = null;
if (isDataEncrypted) {
try {
AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset);
} catch (AlipayApiException e) {
//解密异常, 记录日志
return BaseResponse.error("解密异常",AliPayApiConfig.class.getName());
}
} else {
plainData = content;
}
return BaseResponse.ok(plainData);
}
}
......@@ -4,8 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.wise.sc.pay.business.order.config.Producer;
import cn.wise.sc.pay.business.order.service.IOrdersService;
import cn.wise.sc.pay.business.order.service.Producer;
import cn.wise.sc.pay.business.order.service.strategy.OrderStatisticsStrategyUtil;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.common.core.query.PageWrapperQuery;
......@@ -340,7 +340,7 @@ public class OrderController {
* @return
*/
@PostMapping("/statistics/aggregate")
BaseResponse statisticsAggregate(@RequestBody PageWrapperQuery pageWrapperQuery) {
public BaseResponse statisticsAggregate(@RequestBody PageWrapperQuery pageWrapperQuery) {
return ordersService.statisticsAggregate(pageWrapperQuery);
}
......@@ -351,7 +351,7 @@ public class OrderController {
* @return
*/
@PostMapping("/statistics/goods/market")
BaseResponse statisticsGoodsMarketMoneyGroupSellerGood(@RequestBody PageWrapperQuery pageWrapperQuery) {
public BaseResponse statisticsGoodsMarketMoneyGroupSellerGood(@RequestBody PageWrapperQuery pageWrapperQuery) {
return ordersService.statisticsGoodsMarketMoneyGroupSellerGood(pageWrapperQuery);
}
......
......@@ -3,17 +3,9 @@ package cn.wise.sc.pay.business.order.controller;
import cn.wise.sc.pay.business.order.service.IXpenseTrackerService;
import cn.wise.sc.pay.common.core.model.BaseController;
import cn.wise.sc.pay.common.core.model.BaseResponse;
import cn.wise.sc.pay.common.core.query.PageQuery;
import cn.wise.sc.pay.common.core.query.PageWrapperQueryUtil;
import cn.wise.sc.pay.common.core.util.DateTimeUtils;
import cn.wise.sc.pay.domain.order.model.XpenseTracker;
import cn.wise.sc.pay.common.core.query.PageWrapperQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
......
......@@ -32,7 +32,7 @@
//
// //设置数据源XpenseTracker
// DataSourceConfig dataSourceConfig = new DataSourceConfig();
// dataSourceConfig.setUrl("jdbc:mysql://81.68.92.175:3306/oxo_merchant?useUnicode=true&characterEncoding=UTF-8");
// dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/oxo_merchant?useUnicode=true&characterEncoding=UTF-8");
// dataSourceConfig.setDriverName("com.mysql.cj.jdbc.Driver");
// dataSourceConfig.setUsername("root");
// dataSourceConfig.setPassword("admin!@#123");
......
package cn.wise.sc.pay.business.order.mapper;
import cn.wise.sc.pay.domain.order.model.MerchantPayPro;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @description:
* @author: qh
* @create: 2020-09-16 14:13
**/
@Mapper
public interface MerchantPayProMapper extends BaseMapper<MerchantPayPro> {
}
This diff is collapsed.
This diff is collapsed.
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