瀏覽代碼

微信服务商提交代码

Jimmy 3 年之前
父節點
當前提交
734f71a19f

+ 24 - 0
src/main/java/com/wechat/common/entity/SubLedgerBill.java

@@ -0,0 +1,24 @@
+package com.wechat.common.entity;
+
+import java.util.List;
+import java.util.Map;
+
+
+import lombok.Data;
+
+@Data
+public class SubLedgerBill {
+	
+	private Long amount;	//分账金额
+	
+	private String billDate;//分账日期
+	
+	private String subMchid;//分账特邀商户号
+	
+	private Long payMoney;	// 支付金额
+	
+	private Long refundMoney;//退款金额
+	
+	private List<Map<String,Object>> list;
+	
+}

+ 6 - 2
src/main/java/com/wechat/common/entity/merchant/contact_info/ContactInfo.java

@@ -79,10 +79,14 @@ public class ContactInfo {
 	
 	//给属性赋值
 	public boolean setInfo(RegisterMerchant registerMerchant,X509Certificate certificate,WeChatMerchant wm) {
-		this.setContact_name("王桂光");
+		/*this.setContact_name("王桂光");
 		this.setContact_id_number("450104197011121518");
 		this.setMobile_phone("15103651694");
-		this.setContact_email("847725853@qq.com");
+		this.setContact_email("847725853@qq.com");*/
+		this.setContact_name(registerMerchant.getContactName());
+		this.setContact_id_number(registerMerchant.getContactIdNumber());
+		this.setMobile_phone(registerMerchant.getContactPhone());
+		this.setContact_email(registerMerchant.getContactEmail());
 		encryption(certificate);//敏感信息加密
 		wm.setContact_info(this);
 		return true;

+ 7 - 0
src/main/java/com/wechat/common/entity/sepAccount/KtjReceiversUser.java

@@ -29,4 +29,11 @@ public class KtjReceiversUser {
 	private String failReason;	//分账失败原因
 	
 	private Integer ktjSepRecordId;	//分账账单id
+	
+	private Long amount;	//分账金额
+	
+	private String name;//分账人名称
+	
+	private String subMchid;//特邀商户号
+	
 }

+ 1 - 1
src/main/java/com/wechat/common/entity/sepAccount/Receivers.java

@@ -24,5 +24,5 @@ public class Receivers {
 	
 	private String fail_reason;
 	
-	
+	private Long amount;
 }

+ 13 - 1
src/main/java/com/wechat/controller/WeChatPayJsapiController.java

@@ -82,5 +82,17 @@ public class WeChatPayJsapiController extends BaseController {
 	public void notifyRefund(HttpServletRequest request,HttpServletResponse response) {
 		weChatPayJsapiService.notifyRefund(request,response);
 	}
-
+	
+	/**
+	 * 查询分账账单
+	 * @param subMchid
+	 * @param BillDate  日期格式为2020-05-01
+	 * @return
+	 */
+	@GetMapping(value = "/querySubLedgerBill")
+	public RespWrapper<Object> querySubLedgerBill(String subMchid ,String billDate){
+		return weChatPayJsapiService.querySubLedgerBill(subMchid,billDate);
+	}
+	
+	
 }

+ 11 - 0
src/main/java/com/wechat/controller/merchant/MerchantController.java

@@ -1,5 +1,8 @@
 package com.wechat.controller.merchant;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -30,6 +33,14 @@ public class MerchantController extends BaseController{
 		return merchantService.weChatRegisterMerchant(registerMerchant);
 	} 
 	
+	@GetMapping("/abc")
+	public RespWrapper<Object> abc(String businessCode){
+		Map<String, String> map = new HashMap<String, String>();
+		map.put("businessCode", businessCode);
+		return RespWrapper.makeSuccessResp(map);
+	} 
+	
+	
 	/**
 	 * 根据申请单号查询本系统入驻状态 -- 外部系统调用
 	 * @param businessCode 申请单号

+ 6 - 1
src/main/java/com/wechat/dao/order/KtjJsapiOrderDao.java

@@ -1,10 +1,15 @@
 package com.wechat.dao.order;
 
 
+import java.util.Map;
+
 import com.wechat.common.entity.order.KtjJsapiOrder;
 
+import org.beetl.sql.core.annotatoin.SqlResource;
 import org.beetl.sql.core.mapper.BaseMapper;
-
+@SqlResource("pay.ktjJsapiOrderDao")
 public interface KtjJsapiOrderDao extends BaseMapper<KtjJsapiOrder> {
 
+	Long queryPayMoney(Map<String, Object> map);
+
 }

+ 2 - 0
src/main/java/com/wechat/dao/order/KtjRefundOrderDao.java

@@ -14,4 +14,6 @@ public interface KtjRefundOrderDao extends BaseMapper<KtjRefundOrder> {
 
 	Map<String, Object> queryRefundOrder(KtjRefundOrder reOrder);
 
+	Long queryRefundMoney(Map<String, Object> map);
+
 }

+ 9 - 0
src/main/java/com/wechat/dao/sepAccount/SepRecordDao.java

@@ -1,8 +1,17 @@
 package com.wechat.dao.sepAccount;
 
+import java.util.List;
+import java.util.Map;
+
 import com.wechat.common.entity.sepAccount.KtjSepRecord;
 
+import org.beetl.sql.core.annotatoin.SqlResource;
 import org.beetl.sql.core.mapper.BaseMapper;
 
+@SqlResource("sepRecordDao")
 public interface SepRecordDao extends BaseMapper<KtjSepRecord> {
+
+	Long querySubLedgerBill(Map<String, Object> map);
+
+	List<Map<String,Object>> querySubReceiversUser(Map<String, Object> map);
 }

+ 2 - 0
src/main/java/com/wechat/service/pay/WeChatPayJsapiService.java

@@ -22,5 +22,7 @@ public interface WeChatPayJsapiService {
 	RespWrapper<Object> queryRefundByrefundId(String outRefundNo);
 
 	RespWrapper<Object> queryWechatRefundStatus(String refundId);
+
+	RespWrapper<Object> querySubLedgerBill(String subMchid, String billDate);
    
 }

File diff suppressed because it is too large
+ 66 - 33
src/main/java/com/wechat/service/pay/impl/WeChatPayJsapiServiceImpl.java


+ 42 - 6
src/main/java/com/wechat/service/sepAccount/impl/SepAccountServiceImpl.java

@@ -12,7 +12,6 @@ import com.wechat.common.entity.sepAccount.Receivers;
 import com.wechat.common.entity.sepAccount.help.SepReceiverHelp;
 import com.wechat.common.entity.sepAccount.help.SepUserHandleHelp;
 import com.wechat.common.entity.sepAccount.help.UserSepReceiver;
-import com.wechat.common.enums.RegisterStatus;
 import com.wechat.common.enums.SepAccountEnums;
 import com.wechat.common.parameter.ProjectConstant;
 import com.wechat.common.response.RespWrapper;
@@ -308,8 +307,15 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
     @Override
     public RespWrapper<String> sepAccountHandle(SepUserHandleHelp handleHelp) {
         // 1、校验该商户是否已经添加分账功能
-        RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
-        if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
+        //RespWrapper<Boolean> checkSepFun = checkSepFunction(handleHelp.getSubMchId());
+    	//if(!checkSepFun.isSuccess()) return RespWrapper.makeFailResp(checkSepFun.getMsg());
+        KtjMerchantDetails ktj = new KtjMerchantDetails();
+        ktj.setSubMchid(handleHelp.getSubMchId());
+        ktj = merchantDetailsDao.templateOne(ktj);
+        if(null == ktj || ktj.getRegisterStatus() == null) return RespWrapper.makeFailResp("该商户还没有入驻,请先入驻");
+        if(ktj.getRegisterStatus() == 1) return RespWrapper.makeFailResp("该商户审核中,不能进行分账人设置");
+        if(ktj.getRegisterStatus() == 3) return RespWrapper.makeFailResp("该商户入驻失败,请重新入驻");
+        
         List<KtjSepUser> userList = doFindSepUserList(handleHelp);
         if(userList.isEmpty()) return RespWrapper.makeFailResp("请检查是否设置了分账人");
         // 查询是否有该笔订单
@@ -341,7 +347,8 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
         boolean isOne = true;
         long startTime = System.currentTimeMillis();
         int amount = 0;
-        for(KtjSepUser user:userList){
+        //存储分账用户信息
+        for(KtjSepUser user : userList){
             Float aFloat = Float.valueOf(user.getSepRate());
             int tmpAmount = (int) (aFloat.floatValue()*totalFee);
             KtjSepUserRecord rd = new KtjSepUserRecord();
@@ -350,7 +357,6 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
             rd.setCreateTime(startTime);
             rd.setWxAccount(user.getAccount());
             rd.setAmount(tmpAmount);
-            rd.setWxAccount(user.getAccount());
             addUserList.add(rd);
             amount += tmpAmount;
             if(tmpAmount > 0){
@@ -361,6 +367,16 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
                 sb.append(desc);
             }
         }
+        if(!addUserList.isEmpty()){
+        	//存储商户分账信息
+            KtjSepUserRecord rd = new KtjSepUserRecord();
+            rd.setNickName(ktj.getMerchantName());
+            rd.setGroupName(addUserList.get(0).getGroupName());
+            rd.setCreateTime(startTime);
+            rd.setWxAccount(ktj.getSubMchid());
+            rd.setAmount(Integer.parseInt((totalFee - amount) + ""));
+            addUserList.add(rd);
+        }
         //查询特邀商户appid
         KtjMerchantDetails merchant = new KtjMerchantDetails();
     	merchant.setSubMchid(handleHelp.getSubMchId());
@@ -370,7 +386,7 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
         record.setOutOrderNo(outOrderNo);
         record.setCreateTime(startTime);
         record.setStatus("PROCESSING");//如果发起分账请求成功,则设置成微信处理中
-        record.setAmount(amount);//分账
+        record.setAmount(Integer.parseInt(totalFee + ""));//分账
         record.setSubMchId(handleHelp.getSubMchId());
         record.setTransactionId(handleHelp.getTransactionId());
         record.setSep(false);
@@ -506,9 +522,28 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
                     //存储分账人记录
                     KtjReceiversUser kru = null;
                     List<KtjReceiversUser> listKtjReceiversUser = new ArrayList<KtjReceiversUser>();
+                    //查询所以分账人的名称
                     for (Receivers receivers2 : listReceivers) {
+                    	KtjMerchantDetails ktj = null;
+                    	KtjSepUser ksu = null;
+                    	String name = "";
+                    	//这是商户类型
+                    	if("MERCHANT_ID".equals(receivers2.getType())){
+                    		ktj = new KtjMerchantDetails();
+                    		ktj.setSubMchid(s.getSubMchId());
+                    		ktj = merchantDetailsDao.templateOne(ktj);
+                    		name = null != ktj ? ktj.getMerchantName() : "";
+                    	}else{
+                    		ksu = new KtjSepUser();
+                    		ksu.setAccount(receivers2.getAccount());
+                    		ksu.setSubMchId(s.getSubMchId());
+                    		ksu = sepUserDao.templateOne(ksu);
+                    		name = null != ksu ? ksu.getName() : "";
+                    	}
                     	kru = new KtjReceiversUser();
                     	updateTime(receivers2,record1.getId(),kru);
+                    	kru.setName(name);
+                    	kru.setSubMchid(s.getSubMchId());
                     	listKtjReceiversUser.add(kru);
 					}
                     if(!listKtjReceiversUser.isEmpty()){
@@ -527,6 +562,7 @@ public class SepAccountServiceImpl implements ISepAccountService, DisposableBean
     	kru.setFinishTime(SimpleDateFormatReceiversTime(receivers2.getFinish_time()));
     	kru.setUserType(receivers2.getType());
     	kru.setReceiversResult(receivers2.getResult());
+    	kru.setAmount(receivers2.getAmount());
     	kru.setUserAccount(receivers2.getAccount());
 	}
 

+ 10 - 0
src/main/resources/SQL config/pay/ktjJsapiOrderDao.md

@@ -0,0 +1,10 @@
+queryPayMoney
+===
+SELECT 
+  SUM(total_fee) AS total_fee
+FROM
+  ktj_jsapi_order 
+WHERE order_status = 1 
+  AND sub_mchid = #subMchid# 
+  AND pay_time >= #startTime#
+  AND pay_time <= #endTime#

+ 31 - 20
src/main/resources/SQL config/pay/weChatPayRefund.md

@@ -1,20 +1,31 @@
-queryRefundOrder
-===
-SELECT 
-  kro.id,
-  kro.refund_status,
-  kro.refund_message,
-  kro.sub_mchid,
-  kro.refund_id,
-  kmd.mini_program_sub_appid 
-FROM
-  (SELECT 
-    id,
-    refund_status,
-    refund_message,
-    sub_mchid,
-    refund_id 
-    FROM
-      ktj_refund_order WHERE refund_id = #refundId#) kro 
-    LEFT JOIN ktj_merchant_details kmd 
-      ON kro.sub_mchid = kmd.sub_mchid
+queryRefundOrder
+===
+SELECT 
+  kro.id,
+  kro.refund_status,
+  kro.refund_message,
+  kro.sub_mchid,
+  kro.refund_id,
+  kmd.mini_program_sub_appid 
+FROM
+  (SELECT 
+    id,
+    refund_status,
+    refund_message,
+    sub_mchid,
+    refund_id 
+    FROM
+      ktj_refund_order WHERE refund_id = #refundId#) kro 
+    LEFT JOIN ktj_merchant_details kmd 
+      ON kro.sub_mchid = kmd.sub_mchid
+      
+queryRefundMoney
+===
+SELECT 
+  SUM(refund_fee) AS refund_fee
+FROM
+  ktj_refund_order 
+WHERE refund_status = 1 
+  AND sub_mchid = #subMchid# 
+  AND refund_success_time >= #startTime#
+  AND refund_success_time <= #endTime#

+ 26 - 0
src/main/resources/SQL config/sepRecordDao.md

@@ -0,0 +1,26 @@
+querySubLedgerBill
+===
+SELECT 
+  IFNULL(SUM(amount),0) AS amount
+FROM
+  ktj_sep_record 
+WHERE sub_mch_id = #subMchid# 
+  AND STATUS = 'FINISHED' 
+  AND finish_time >= #startTime#
+  AND finish_time <= #endTime#
+  
+querySubReceiversUser
+===
+SELECT 
+  fail_reason,
+  finish_time,
+  receivers_result,
+  user_account,
+  user_type,
+  amount,
+  name 
+FROM
+  ktj_receivers_user 
+WHERE finish_time >= #startTime#
+  AND finish_time <= #endTime#
+  AND sub_mchid =#subMchid#