Bläddra i källkod

Merge remote-tracking branch 'origin/dev' into dev

hmp 4 år sedan
förälder
incheckning
1cac8020e3

+ 64 - 55
ldt-core/src/main/java/org/springblade/flow/shop/task/QueryAuthStatus.java

@@ -9,13 +9,9 @@ import com.yeepay.yop.sdk.service.common.response.YopResponse;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.flowable.engine.TaskService;
-import org.flowable.engine.impl.persistence.entity.CommentEntityImpl;
-import org.flowable.engine.task.Comment;
 import org.flowable.task.api.Task;
 import org.springblade.common.cache.FlowCache;
 import org.springblade.core.log.exception.ServiceException;
-import org.springblade.core.sms.model.SmsData;
-import org.springblade.core.tool.api.R;
 import org.springblade.flow.business.constant.AuditCandidate;
 import org.springblade.flow.business.service.FlowBusinessService;
 import org.springblade.flow.core.entity.BladeFlow;
@@ -26,26 +22,22 @@ import org.springblade.ldt.shop.entity.Audit;
 import org.springblade.ldt.shop.entity.Shop;
 import org.springblade.ldt.shop.service.IAuditService;
 import org.springblade.ldt.shop.service.IShopService;
-import org.springblade.modules.resource.enums.SmsCodeEnum;
-import org.springblade.modules.resource.utils.SmsUtil;
-import org.springblade.wx.config.ConfigForClient;
-import org.springblade.wx.config.ConfigForMall;
 import org.springblade.wx.config.ConfigForShop;
 import org.springblade.wx.constant.MessageTemplate;
 import org.springblade.wx.constant.MiniProgramType;
 import org.springblade.wx.service.WeChatService;
 import org.springblade.wx.utils.UrlTransform;
-import org.springblade.yeePay.common.YeePayConst;
 import org.springblade.yeePay.common.YeepayApiConstant;
-import org.springblade.yeePay.entity.ConfigAppDto;
-import org.springblade.yeePay.service.YeepayCommonService;
 import org.springblade.yeePay.service.YeepaySaasService;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 
-import java.util.*;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
 
 /**
  * @author: lianghanqiang
@@ -67,39 +59,44 @@ public class QueryAuthStatus {
 	private IAppShopService appShopService;
 
 	/**
-	 * 	5分钟轮询微信认证列表
-	 * 	用户申请状态待认证就通知用户进行账户确认
-	 * */
+	 * 5分钟轮询微信认证列表
+	 * 用户申请状态待认证就通知用户进行账户确认
+	 */
 	@Scheduled(cron = "0 */1 * * * ?")
-	void queryStatus(){
+	void queryStatus() {
 		//查询当前微信认证队列各个状态
 		Set<AuthInfoData> authList = FlowCache.authList();
-		if(Objects.isNull(authList)){
+		if (Objects.isNull(authList)) {
 			log.info("暂无认证队列");
 			return;
 		}
 		authList.parallelStream().forEach(item -> {
-			try{
+			try {
 				YopResponse yopResponse = yeepaySaasService.wechatAuthQuery(item);
 				JSONObject resObj = JSON.parseObject(yopResponse.getStringResult());
 				String applymentState = resObj.getString("applymentState");
 				//状态为待用户验证
-				if (Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_WAITTING_FOR_CONFIRM_CONTACT.name(),applymentState)) {
-					prepareForAuth(item,resObj);
+				boolean confirm = Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_WAITTING_FOR_CONFIRM_CONTACT.name(), applymentState);
+				if (confirm) {
+					prepareForAuth(item, resObj);
 				}
 
-				//状态为驳回
-				if (Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_REJECTED.name(),applymentState)) {
-					applyReject(item,resObj.getString("rejectReason"));
+				//状态为已完成认证
+				boolean passed = Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_PASSED.name(), applymentState) ||
+					Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_FREEZED.name(), applymentState);
+				if (passed) {
+					completeFlow(item, resObj.getString("rejectReason"));
 				}
 
-				//状态为已完成认证
-				if (Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_PASSED.name(),applymentState)) {
-					completeFlow(item);
+				//状态为驳回
+				boolean rejected = Objects.equals(YeepayApiConstant.applymentState.APPLYMENT_STATE_REJECTED.name(), applymentState);
+				if (rejected || (!passed && !confirm)) {
+					applyReject(item, resObj.getString("rejectReason"));
 				}
-			}catch (Exception e){
-				log.error(String.format("查询微信认证状态异常:%s",e.getMessage()));
-				applyReject(item,String.format("查询微信认证状态异常:%s",e.getMessage()));
+
+			} catch (Exception e) {
+				log.error(String.format("查询微信认证状态异常:%s", e.getMessage()));
+				applyReject(item, String.format("查询微信认证状态异常:%s", e.getMessage()));
 			}
 		});
 	}
@@ -108,7 +105,7 @@ public class QueryAuthStatus {
 	 * 用户申请驳回
 	 * */
 	public void applyReject(AuthInfoData item, String failReason) {
-		log.info(String.format("商户实名申请驳回,商户:%s;驳回原因:%s",item.getAudit().getShortName(),failReason));
+		log.info(String.format("商户实名申请驳回,商户:%s;驳回原因:%s", item.getAudit().getShortName(), failReason));
 		Audit audit = auditService.getById(Convert.toLong(item.getVariables().get("auditId")));
 		Shop shop = shopService.getById(Convert.toLong(item.getVariables().get("shopId")));
 		audit.setAuditStatus(ShopEnum.FAIL.name());
@@ -116,16 +113,20 @@ public class QueryAuthStatus {
 		List<Task> list = taskService.createTaskQuery().processInstanceId(audit.getProcessInstanceId()).taskAssignee(AuditCandidate.$INITIATOR.name()).active().list();
 		Task task = list.get(0);
 		taskService.addComment(task.getId(), task.getProcessInstanceId(), failReason);
-		Assert.isTrue(auditService.saveOrUpdate(audit),()->{throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新资料失败!");});
-		Assert.isTrue(shopService.saveOrUpdate(shop),()->{throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新审核状态失败!");});
+		Assert.isTrue(auditService.saveOrUpdate(audit), () -> {
+			throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新资料失败!");
+		});
+		Assert.isTrue(shopService.saveOrUpdate(shop), () -> {
+			throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新审核状态失败!");
+		});
 		FlowCache.removeAuthMember(item);
 	}
 
 	/**
-	 * 	用户已完成授权,流程完成
-	 * */
+	 * 用户已完成授权,流程完成
+	 */
 	@Transactional
-	public void completeFlow(AuthInfoData item) {
+	public void completeFlow(AuthInfoData item, String failReason) {
 		Audit audit = auditService.getById(Convert.toLong(item.getVariables().get("auditId")));
 		Shop shop = shopService.getById(Convert.toLong(item.getVariables().get("shopId")));
 		BladeFlow bladeFlow = new BladeFlow();
@@ -134,29 +135,37 @@ public class QueryAuthStatus {
 
 		IPage<BladeFlow> bladeFlowIPage = flowBusinessService.selectTodoPage(new Page<BladeFlow>(), bladeFlow);
 		BladeFlow task = bladeFlowIPage.getRecords().get(0);
-		Assert.notNull(task,()->{ throw  new ServiceException("商户:"+shop.getId()+" 完成商户认证--》 查询流程任务失败!"); });
+		Assert.notNull(task, () -> {
+			throw new ServiceException("商户:" + shop.getId() + " 完成商户认证--》 查询流程任务失败!");
+		});
 
 		task.setPass(Boolean.TRUE);
 		task.setComment("商户入驻成功!");
-		task.getVariables().put("applyPass",Boolean.TRUE);
+		task.getVariables().put("applyPass", Boolean.TRUE);
+		task.getVariables().put("failReason", failReason);
 		audit.setAuditStatus(ShopEnum.PASS.name());
 		shop.setAuditStatus(ShopEnum.PASS.name());
 
 		//配置小程序信息
 		appShopService.configApp(shop);
 
-		Assert.isTrue(flowBusinessService.completeTask(task),()->{throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 执行任务失败!");});
-		Assert.isTrue(auditService.saveOrUpdate(audit),()->{throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新资料失败!");});
-		Assert.isTrue(shopService.saveOrUpdate(shop),()->{throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新审核状态失败!");});
+		Assert.isTrue(flowBusinessService.completeTask(task), () -> {
+			throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 执行任务失败!");
+		});
+		Assert.isTrue(auditService.saveOrUpdate(audit), () -> {
+			throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新资料失败!");
+		});
+		Assert.isTrue(shopService.saveOrUpdate(shop), () -> {
+			throw new ServiceException("商户:\"+shop.getId()+\" 完成商户认证--》 更新审核状态失败!");
+		});
 
 		FlowCache.removeAuthMember(item);
 	}
 
 
-
 	/**
-	 * 	通知用户
-	 * */
+	 * 通知用户
+	 */
 	private void sendMessageToUser(AuthInfoData item) {
 		try {
 
@@ -167,19 +176,19 @@ public class QueryAuthStatus {
 
 			//微信模板消息
 			String openId = item.getShop().getOpenId();
-			String contentStr = String.format(MessageTemplate.INVITATION_SIGN.getContentString(),configForShop.getAppName(),"进入小程序完成认证");
+			String contentStr = String.format(MessageTemplate.INVITATION_SIGN.getContentString(), configForShop.getAppName(), "进入小程序完成认证");
 			JSONObject content = JSON.parseObject(contentStr);
-			weChatService.sendTemplateMessage(openId, MessageTemplate.INVITATION_SIGN,content,configForShop.getAuthPage(), MiniProgramType.SHOP);
+			weChatService.sendTemplateMessage(openId, MessageTemplate.INVITATION_SIGN, content, configForShop.getAuthPage(), MiniProgramType.SHOP);
 
-		}catch (Exception e){
+		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
 
 
 	/**
-	 *  认证二维码写进流程变量
-	 * */
+	 * 认证二维码写进流程变量
+	 */
 	private void notifyUserTask(AuthInfoData item, JSONObject resObj) {
 		Audit audit = auditService.getById(Convert.toLong(item.getVariables().get("auditId")));
 		Shop shop = shopService.getById(audit.getEntityId());
@@ -193,7 +202,7 @@ public class QueryAuthStatus {
 		Map<String, Object> variables = task.getVariables();
 		String authUrl = resObj.getString("qrcodeUrl");
 		variables.put("qrcodeUrl", UrlTransform.cheakUrl(authUrl));
-		taskService.setVariables(task.getTaskId(),variables);
+		taskService.setVariables(task.getTaskId(), variables);
 		shop.setAuditStatus(ShopEnum.WAITING_AUTH.name());
 		audit.setAuditStatus(ShopEnum.WAITING_AUTH.name());
 		shopService.saveOrUpdate(shop);
@@ -201,18 +210,18 @@ public class QueryAuthStatus {
 	}
 
 
-	private void prepareForAuth(AuthInfoData item, JSONObject resObj){
+	private void prepareForAuth(AuthInfoData item, JSONObject resObj) {
 //		if( Objects.isNull(item.getIsNotify()) || !item.getIsNotify()){
 //
 //		}
 		FlowCache.removeAuthMember(item);
-		try{
-			notifyUserTask(item,resObj);
+		try {
+			notifyUserTask(item, resObj);
 			sendMessageToUser(item);
 			item.setIsNotify(Boolean.TRUE);
-		}catch (Exception e){
-			log.error("通知用户认证异常:"+ e.getMessage());
-		}finally {
+		} catch (Exception e) {
+			log.error("通知用户认证异常:" + e.getMessage());
+		} finally {
 			FlowCache.addAuthMember(item);
 		}
 	}

+ 2 - 2
ldt-core/src/main/java/org/springblade/flow/shop/task/callback/ShopInvitationSuccessCallback.java

@@ -76,8 +76,8 @@ public class ShopInvitationSuccessCallback implements ShopInvitationCallback {
 		Assert.isTrue(flowBusinessService.completeTask(task),()->{ throw new ServiceException(" 商户入驻回调异常: 入驻申请驳回处理异常! "); });
 
 		//修改审核状态
-		audit.setAuditStatus(ShopEnum.WAITING_AUTH.name());
-		shop.setAuditStatus(ShopEnum.WAITING_AUTH.name());
+//		audit.setAuditStatus(ShopEnum.WAITING_AUTH.name());
+//		shop.setAuditStatus(ShopEnum.WAITING_AUTH.name());
 
 		Assert.isTrue(auditService.saveOrUpdate(audit),()->{ throw new ServiceException(" 商户入驻回调异常: 入驻申请驳回处理异常! "); });
 		Assert.isTrue(shopService.saveOrUpdate(shop),()->{ throw new ServiceException(" 商户入驻回调异常: 入驻申请驳回处理异常! "); });

+ 71 - 0
ldt-core/src/main/java/org/springblade/gateway/web_gateway/controller/BillTraceController.java

@@ -0,0 +1,71 @@
+package org.springblade.gateway.web_gateway.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.gateway.web_gateway.entity.dto.BillDataCensusDto;
+import org.springblade.ldt.bills.entity.*;
+import org.springblade.ldt.bills.service.*;
+import org.springblade.ldt.bills.vo.BillsVO;
+import org.springblade.ldt.bills.wrapper.BillsWrapper;
+import org.springblade.ldt.mall.service.IMallService;
+import org.springblade.ldt.shop.service.IShopService;
+import org.springblade.ldt.user.service.ILoginUserService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 账单追溯
+ */
+@RestController
+@RequestMapping("/web/billTrace")
+@Api(tags = "账单追溯")
+@AllArgsConstructor
+public class BillTraceController {
+
+	private ILoginUserService loginUserService;
+	private IShopService shopService;
+	private IMallService mallService;
+	private IBillsService billsService;
+	private IPointBillsService pointBillsService;
+	private IBalanceBillsService balanceBillsService;
+	private IFrozenRecService frozenRecService;
+	private IPlatformBillsService platformBillsService;
+
+	@GetMapping()
+	@ApiOperation(value = "账单追溯")
+	public R getBillTrace(@ApiParam(required = true) Long billId) {
+		BillDataCensusDto billDataCensusDto = null;
+		Bills bills = billsService.getById(billId);
+		if (ObjectUtils.isNotEmpty(bills)) {
+			PointBills pointBills = pointBillsService.getOne(Wrappers.<PointBills>lambdaQuery().eq(PointBills::getTradeNo, bills.getId()));
+			BalanceBills balanceBills = balanceBillsService.getOne(Wrappers.<BalanceBills>lambdaQuery().eq(BalanceBills::getTradeNo, bills.getId()));
+			FrozenRec frozenRec = frozenRecService.getOne(Wrappers.<FrozenRec>lambdaQuery().eq(FrozenRec::getTradeNo, bills.getId()));
+			PlatformBills platformBills = platformBillsService.getOne(Wrappers.<PlatformBills>lambdaQuery().eq(PlatformBills::getTradeNo, bills.getId()));
+			billDataCensusDto = BillDataCensusDto.builder()
+				.bills(bills)
+				.pointBills(pointBills)
+				.balanceBills(balanceBills)
+				.frozenRec(frozenRec)
+				.platformBills(platformBills)
+				.build();
+		}
+		return R.data(billDataCensusDto);
+	}
+
+	@GetMapping("/getBills")
+	@ApiOperation(value = "账单列表分页", notes = "传入bills")
+	public R<IPage<BillsVO>> list(Bills bills, Query query) {
+		IPage<Bills> iPage = billsService.page(Condition.getPage(query), Wrappers.<Bills>lambdaQuery().orderByDesc(Bills::getCreateTime));
+		return R.data(BillsWrapper.build(loginUserService, shopService, mallService).pageVO(iPage));
+	}
+
+}

+ 26 - 0
ldt-core/src/main/java/org/springblade/gateway/web_gateway/entity/dto/BillDataCensusDto.java

@@ -0,0 +1,26 @@
+package org.springblade.gateway.web_gateway.entity.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springblade.ldt.bills.entity.*;
+
+/**
+ * @author July
+ * @version 1.0.0
+ * @ClassName BillDataCensusDto.java
+ * @Description 账单数据统计DTO
+ * @createTime 2021年11月11日 18:30:00
+ */
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class BillDataCensusDto {
+	private Bills bills;
+	private PointBills pointBills;
+	private BalanceBills balanceBills;
+	private PlatformBills platformBills;
+	private FrozenRec frozenRec;
+}

+ 1 - 1
ldt-core/src/main/java/org/springblade/modules/resource/builder/sms/client/HwClient.java

@@ -65,7 +65,7 @@ public class HwClient {
 	 * @param smsData
 	 * */
 	private String fetchParams(SmsData smsData) {
-		return Convert.toStr(smsData.getParams().values());
+		return JSON.toJSONString(smsData.getParams().values());
 	}
 
 	public static void main(String[] args) {

+ 1 - 1
ldt-core/src/main/java/org/springblade/yeePay/common/YeepayApiConstant.java

@@ -274,7 +274,7 @@ public interface YeepayApiConstant {
 		APPLYMENT_STATE_WAITTING_FOR_CONFIRM_LEGALPERSON,//待账户验证
 		APPLYMENT_STATE_PASSED,//审核通过
 		APPLYMENT_STATE_REJECTED,//审核驳回
-		APPLYMENT_STATE_FREEZED,//已冻结
+		APPLYMENT_STATE_FREEZED,//已冻结(该主体已完成过商家注册,无需重复注册)
 		APPLYMENT_STATE_CANCELED,//已作废
 	}
 

+ 19 - 3
ldt-core/src/main/java/org/springblade/yeePay/controller/YeepayController.java

@@ -6,6 +6,8 @@ import com.yeepay.yop.sdk.service.common.response.YopResponse;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springblade.common.cache.PlatformCache;
+import org.springblade.common.config.yeepay.OpenProduct;
 import org.springblade.core.log.annotation.ApiLog;
 import org.springblade.core.log.logger.BladeLogger;
 import org.springblade.core.tool.api.R;
@@ -23,6 +25,11 @@ import org.springblade.yeePay.entity.saas.trade.TradeOrderQueryDto;
 import org.springblade.yeePay.service.YeepayCommonService;
 import org.springblade.yeePay.service.YeepaySaasService;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 /**
  * @author: lianghanqiang
@@ -99,10 +106,10 @@ public class YeepayController {
 		return R.data(yeepayCommonService.queryApp(parentMerchantNo,merchantNo,appIdType));
 	}
 
-	@GetMapping("/upload")
+	@PostMapping("/upload")
 	@ApiOperation("上传文件")
-	public R upload(String multipartFile){
-		return R.data(yeepayCommonService.addFileToYeepay(multipartFile));
+	public R upload( MultipartFile file){
+ 		return R.data(yeepayCommonService.addFileToYeepay(file));
 	}
 
 	@GetMapping("/queryBalance")
@@ -193,4 +200,13 @@ public class YeepayController {
 		return R.success("s");
 	}
 
+	public static void main(String[] args) {
+		List<InvitationDto.ProductInfo> productInfos = new ArrayList<>(32);
+		Arrays.stream(OpenProduct.MICRO_PRODUCTS).forEach(item -> {
+			InvitationDto.ProductInfo productInfo = PlatformCache.productInfo(item);
+			productInfo.setProductName(null);
+			productInfos.add(productInfo);
+		});
+
+	}
 }

+ 1 - 1
ldt-core/src/main/resources/application-prod.yml

@@ -54,7 +54,7 @@ blade:
   #分布式锁配置
   lock:
     ##是否启用分布式锁
-    enabled: true
+    enabled: false
     ##将docker脚本部署的redis服务映射为宿主机ip
     ##生产环境推荐使用阿里云高可用redis服务并设置密码
     address: redis://127.0.0.1:6379

+ 8 - 4
ldt-core/src/main/resources/application.yml

@@ -256,11 +256,15 @@ blade:
 crypto:
   key: uAY9ugkHQpvozZeA
   whiteList:
+    - /yeepay
     - /put-file
-    - /payment/callback/
-    - /payment/csurl/
-    - /withdraw/callback/
-    - /withdraw/csurl/
+    - /blade-test
+    - /common/account
+    - /payment
+    - /sms
+    - /mall/yeepay/product/fee/modifyProductFeeNotify
+    - /shop/yeepay/product/fee/modifyProductFeeNotify
+    - /withdraw
     - /pressure_test/scanPay
     - /pressure_test/deCodeNotifyData