Jimmy hace 4 años
padre
commit
df2d4637c4
Se han modificado 15 ficheros con 552 adiciones y 119 borrados
  1. 18 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/ComtikaWechatClientProperties.java
  2. 20 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/ComtikaWechatProperties.java
  3. 10 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/WechatClientConfig.java
  4. 85 52
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/core/timer/ComtikaMyBankTimer.java
  5. 21 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/dao/comtika/SysComtikaBillDao.java
  6. 20 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/dao/comtika/SysComtikaSubUserDao.java
  7. 31 9
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/MybankPay.java
  8. 50 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SubLedgerBill.java
  9. 31 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SysComtikaBill.java
  10. 32 0
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SysComtikaSubUser.java
  11. 47 39
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/service/comtika/ComtikaMerchantService.java
  12. 97 17
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/service/comtika/impl/ComtikaMerchantServiceImpl.java
  13. 48 2
      ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/web/ComtikaController.java
  14. 33 0
      ctkcloud-mybank-service/src/main/resources/sql/comtika/sysComtikaBillDao.md
  15. 9 0
      ctkcloud-mybank-service/src/main/resources/sql/comtika/sysComtikaSubUserDao.md

+ 18 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/ComtikaWechatClientProperties.java

@@ -0,0 +1,18 @@
+package com.comtika.ctkcloud.server.config;
+
+import lombok.Data;
+
+/**
+ * 配置参数实体类
+ */
+@Data
+public class ComtikaWechatClientProperties {
+    private String appCode;//小程序code,自定义编码,与配置表pub_app_config一一对应
+
+    private String appText;//文本描述
+
+    private String payMchid;//云平台商户号
+
+
+   
+}

+ 20 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/ComtikaWechatProperties.java

@@ -0,0 +1,20 @@
+package com.comtika.ctkcloud.server.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+
+/**
+ * 获取配置参数,设置配置
+ */
+@ConfigurationProperties(prefix = "comtika.jsapi")
+public class ComtikaWechatProperties {
+	private ComtikaWechatClientProperties[] clients = {};
+
+    public ComtikaWechatClientProperties[] getClients() {
+        return clients;
+    }
+
+    public void setClients(ComtikaWechatClientProperties[] clients) {
+        this.clients = clients;
+    }
+}

+ 10 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/config/WechatClientConfig.java

@@ -0,0 +1,10 @@
+package com.comtika.ctkcloud.server.config;
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableConfigurationProperties(ComtikaWechatProperties.class)
+public class WechatClientConfig
+{
+}

+ 85 - 52
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/core/timer/ComtikaMyBankTimer.java

@@ -1,52 +1,85 @@
-package com.comtika.ctkcloud.server.core.timer;
-
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import com.comtika.ctkcloud.server.constant.enums.ComtikaRegisterStatus;
-import com.comtika.ctkcloud.server.dao.comtika.SysComtikaMerchantDao;
-import com.comtika.ctkcloud.server.entity.comtikawechat.SysComtikaMerchant;
-import com.comtika.ctkcloud.server.service.comtika.ComtikaMerchantService;
-
-
-@Configuration
-@EnableScheduling //康体佳定时器总开关
-public class ComtikaMyBankTimer {
-	
-	@Autowired
-	private ComtikaMerchantService comtikaMerchantService;
-	
-	@Autowired
-	private SysComtikaMerchantDao sysComtikaMerchantDao;
-	
-	/**
-	 * 定时任务,每天23点确认分账账单。防止未确认的存在数据库
-	 */
-	@Scheduled(cron ="0 0 23 * * ? ")
-	public void comtikaOrderNotice(){
-		comtikaMerchantService.comtikaOrderNotice();
-	}
-	
-	/**
-	 * 定时任务,每天5分钟查询入驻状态
-	 */
-	@Scheduled(cron ="0 0/5 * * * ? ")
-	public void queryWeChatRegisterMerchant(){
-		System.out.println("******开始查询入驻信息");
-		SysComtikaMerchant sysComtikaMerchant = new SysComtikaMerchant();
-		sysComtikaMerchant.setRegisterStatus(ComtikaRegisterStatus.EXAMINE.getStatus());
-		List<SysComtikaMerchant>list = sysComtikaMerchantDao.template(sysComtikaMerchant);
-		if(!list.isEmpty()){
-			for (SysComtikaMerchant sysComtikaMerchant2 : list) {
-				String businessCode = sysComtikaMerchant2.getBusinessCode();
-				comtikaMerchantService.queryWeChatRegisterMerchant(businessCode);
-			}
-			
-		}
-		
-	}
-}
+package com.comtika.ctkcloud.server.core.timer;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+
+import com.comtika.ctkcloud.common.result.RespWrapper;
+import com.comtika.ctkcloud.server.constant.enums.ComtikaRegisterStatus;
+import com.comtika.ctkcloud.server.dao.comtika.SysComtikaMerchantDao;
+import com.comtika.ctkcloud.server.entity.comtikawechat.SysComtikaMerchant;
+import com.comtika.ctkcloud.server.service.comtika.ComtikaMerchantService;
+
+
+@Configuration
+@EnableScheduling //康体佳定时器总开关
+public class ComtikaMyBankTimer {
+	
+	@Autowired
+	private ComtikaMerchantService comtikaMerchantService;
+	
+	@Autowired
+	private SysComtikaMerchantDao sysComtikaMerchantDao;
+	
+	/**
+	 * 定时任务,每天23点确认分账账单。防止未确认的存在数据库
+	 */
+	@Scheduled(cron ="0 0 23 * * ? ")
+	public void comtikaOrderNotice(){
+		comtikaMerchantService.comtikaOrderNotice();
+	}
+	
+	/**
+	 * 定时任务,每天12查询分账账单
+	 */
+	@Scheduled(cron ="0 0 12 * * ? ")
+	public void comtikaSubLedgerBill(){
+		SysComtikaMerchant sys = new SysComtikaMerchant();
+		sys.setRegisterStatus(ComtikaRegisterStatus.SUCCESS.getStatus());
+		List<SysComtikaMerchant> list = sysComtikaMerchantDao.template(sys);
+		if(list.isEmpty())return;
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(new Date());
+		calendar.add(calendar.DATE, -1);
+        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd");
+        String billDate = simple.format(calendar.getTime());
+		for (SysComtikaMerchant sysComtikaMerchant : list) {
+			RespWrapper<Object> data = comtikaMerchantService.comtikaSubLedgerBill(sysComtikaMerchant,billDate);
+		}
+	}
+	
+	public static void main(String[] args) {
+		Calendar calendar = new GregorianCalendar();
+		calendar.setTime(new Date());
+		calendar.add(calendar.DATE, -1);
+        SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd");
+        String billDate = simple.format(calendar.getTime());
+        System.out.println(billDate);
+	}
+	/**
+	 * 定时任务,每天5分钟查询入驻状态
+	 */
+	@Scheduled(cron ="0 0/5 * * * ? ")
+	public void queryWeChatRegisterMerchant(){
+		System.out.println("******开始查询入驻信息");
+		SysComtikaMerchant sysComtikaMerchant = new SysComtikaMerchant();
+		sysComtikaMerchant.setRegisterStatus(ComtikaRegisterStatus.EXAMINE.getStatus());
+		List<SysComtikaMerchant>list = sysComtikaMerchantDao.template(sysComtikaMerchant);
+		if(!list.isEmpty()){
+			for (SysComtikaMerchant sysComtikaMerchant2 : list) {
+				String businessCode = sysComtikaMerchant2.getBusinessCode();
+				comtikaMerchantService.queryWeChatRegisterMerchant(businessCode);
+			}
+			
+		}
+		
+	}
+}

+ 21 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/dao/comtika/SysComtikaBillDao.java

@@ -0,0 +1,21 @@
+package com.comtika.ctkcloud.server.dao.comtika;
+
+
+import java.util.Map;
+
+import com.comtika.ctkcloud.server.entity.comtikapay.SysComtikaBill;
+
+import org.beetl.sql.core.annotatoin.SqlResource;
+import org.beetl.sql.core.engine.PageQuery;
+import org.beetl.sql.core.mapper.BaseMapper;
+
+
+
+@SqlResource("comtika.sysComtikaBillDao")
+public interface SysComtikaBillDao extends BaseMapper<SysComtikaBill> {
+
+	PageQuery<Map<String, Object>> queryComtikaBill(PageQuery<Map<String, Object>> pageQery);
+
+
+
+}

+ 20 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/dao/comtika/SysComtikaSubUserDao.java

@@ -0,0 +1,20 @@
+package com.comtika.ctkcloud.server.dao.comtika;
+
+
+import java.util.Map;
+
+import com.comtika.ctkcloud.server.entity.comtikapay.SysComtikaSubUser;
+
+import org.beetl.sql.core.annotatoin.SqlResource;
+import org.beetl.sql.core.engine.PageQuery;
+import org.beetl.sql.core.mapper.BaseMapper;
+
+
+
+@SqlResource("comtika.sysComtikaSubUserDao")
+public interface SysComtikaSubUserDao extends BaseMapper<SysComtikaSubUser> {
+
+	PageQuery<Map<String, Object>> queryComtikaBillUser(PageQuery<Map<String, Object>> pageQery);
+
+
+}

+ 31 - 9
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/MybankPay.java

@@ -1,5 +1,7 @@
 package com.comtika.ctkcloud.server.entity;
 
+import lombok.Data;
+
 import com.comtika.ctkcloud.common.enums.pay.PayTypeEnum;
 import com.comtika.ctkcloud.server.base.UnifyPayModel;
 
@@ -17,89 +19,109 @@ public class MybankPay {
 	private Integer chargerMode;//充电模式
 	private Integer chargerValue;//充电值
 	private String formId;//消息推送
-
+	
 	public MybankPay(){
 		payType = PayTypeEnum.WECHAT.getId();
 		payModel = UnifyPayModel.BALANCE_PAY.getId();
 	}
-
+	
+	
 	public Long getTotalFee() {
 		return totalFee;
 	}
 
+
 	public void setTotalFee(Long totalFee) {
 		this.totalFee = totalFee;
 	}
 
+
 	public Long getId() {
 		return id;
 	}
 
+
 	public void setId(Long id) {
 		this.id = id;
 	}
 
+
 	public Integer getPayModel() {
 		return payModel;
 	}
 
+
 	public void setPayModel(Integer payModel) {
 		this.payModel = payModel;
 	}
 
+
 	public Integer getPayType() {
 		return payType;
 	}
 
+
 	public void setPayType(Integer payType) {
 		this.payType = payType;
 	}
 
+
 	public Long getOrderId() {
 		return orderId;
 	}
 
+
 	public void setOrderId(Long orderId) {
 		this.orderId = orderId;
 	}
 
+
 	public String getStreamNo() {
 		return streamNo;
 	}
 
+
 	public void setStreamNo(String streamNo) {
 		this.streamNo = streamNo;
 	}
 
+
 	public Integer getChargerMode() {
 		return chargerMode;
 	}
 
+
 	public void setChargerMode(Integer chargerMode) {
 		this.chargerMode = chargerMode;
 	}
 
+
 	public Integer getChargerValue() {
 		return chargerValue;
 	}
 
+
 	public void setChargerValue(Integer chargerValue) {
 		this.chargerValue = chargerValue;
 	}
 
+
 	public String getFormId() {
 		return formId;
 	}
 
+
 	public void setFormId(String formId) {
 		this.formId = formId;
 	}
 
-	@Override
-	public String toString() {
-		return "MybankPay [totalFee=" + totalFee + ", id=" + id + ", payModel="
-				+ payModel + ", payType=" + payType + ", orderId=" + orderId
-				+ ", streamNo=" + streamNo + ", chargerMode=" + chargerMode
-				+ ", chargerValue=" + chargerValue + ", formId=" + formId + "]";
-	}
+
+
+
+
+	
+
+	
+
+	
 }

+ 50 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SubLedgerBill.java

@@ -0,0 +1,50 @@
+package com.comtika.ctkcloud.server.entity.comtikapay;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+
+
+
+import lombok.Data;
+
+@Data
+public class SubLedgerBill {
+	
+	private Long amount;	//分账金额
+	
+	private String billDate;//分账日期
+	
+	private String subMchid;//分账特邀商户号
+	
+	private Long payMoney;	// 支付金额
+	
+	private Long refundMoney;//退款金额
+	
+	private List<SysComtikaSubUser> list;
+
+	@Override
+	public String toString() {
+		return "SubLedgerBill [amount=" + amount + ", billDate=" + billDate
+				+ ", subMchid=" + subMchid + ", payMoney=" + payMoney
+				+ ", refundMoney=" + refundMoney + ", list=" + list + "]";
+	}
+
+	public void assignmentSysComtikaBill(SysComtikaBill sysComtikaBill) {
+		sysComtikaBill.setAmount(this.amount);
+		sysComtikaBill.setPayMoney(this.payMoney == null ? 0L : this.payMoney);
+		sysComtikaBill.setRefundMoney(this.refundMoney == null ? 0L : this.refundMoney);
+		sysComtikaBill.setSubMchid(this.subMchid);
+		SimpleDateFormat simp = new SimpleDateFormat("yyyy-MM-dd");
+		//获取分账日期后再加上十二小时的时间戳,防止前端传值的时候大于当前分账日期的时间戳
+		try {
+			Long time = simp.parse(this.billDate).getTime() + 12 * 60 * 60 * 1000;
+			sysComtikaBill.setBillDate(time);
+		} catch (ParseException e) {
+			e.printStackTrace();
+		}
+		
+	}
+	
+}

+ 31 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SysComtikaBill.java

@@ -0,0 +1,31 @@
+package com.comtika.ctkcloud.server.entity.comtikapay;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+import lombok.Data;
+
+@Data
+public class SysComtikaBill {
+	
+	@Id
+	@GeneratedValue(strategy = GenerationType.AUTO)
+	@Column(name = "id")
+	private Long id;	//数据库表id
+	
+	private Long amount;	//分账金额
+	
+	private Long payMoney;	//支付金额
+	
+	private Long refundMoney;	//退款金额
+	
+	private String subMchid;	//特邀商户号
+	
+	private Long merchantId;	//云平台商户id
+	
+	private String merchantName;//商户名称
+	
+	private Long billDate;	//账单日期
+}	

+ 32 - 0
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/entity/comtikapay/SysComtikaSubUser.java

@@ -0,0 +1,32 @@
+package com.comtika.ctkcloud.server.entity.comtikapay;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+import lombok.Data;
+
+@Data
+public class SysComtikaSubUser {
+	
+	@Id
+	@GeneratedValue(strategy = GenerationType.AUTO)
+	@Column(name = "id")
+	private Long id;
+	
+	private Long finishTime;		//分账时间
+	
+	private Long amount;			//分账金额
+	
+	private String receiversResult;	//分账状态
+	
+	private String userAccount;		//分账用户帐号
+	
+	private String name;			//分账用户名词
+	
+	private String userType;		//分账用户类型
+	
+	private Long sysComtikaBillId;
+	
+}

+ 47 - 39
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/service/comtika/ComtikaMerchantService.java

@@ -1,39 +1,47 @@
-package com.comtika.ctkcloud.server.service.comtika;
-
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.web.multipart.MultipartFile;
-
-import com.comtika.ctkcloud.common.result.RespWrapper;
-import com.comtika.ctkcloud.server.entity.MybankPay;
-import com.comtika.ctkcloud.server.entity.comtikawechat.ComtikaRegisterMerchant;
-import com.comtika.ctkcloud.server.entity.order.CtkRechargeOrder;
-
-public interface ComtikaMerchantService {
-
-	RespWrapper<Object> weChatRegisterMerchant(ComtikaRegisterMerchant comtikaRegisterMerchant);
-
-	RespWrapper<Object> queryWeChatRegisterMerchant(String businessCode);
-
-	RespWrapper<Object> jsapiUnifiedOrder(MybankPay mybankPay, String ip,Long userId);
-
-	void notify(HttpServletResponse response, HttpServletRequest request);
-
-	RespWrapper<Object> comtikaPrePay(MybankPay mybankPay, Long userId,String ip);
-
-	RespWrapper<Object> refundComtika(Long rechargeOrderId,String payOrderId, Long refundAmount,Long merchantId,Long customerId);
-
-	RespWrapper<Object> comtikaOrderNotice(CtkRechargeOrder ctk);
-
-	void comtikaOrderNotice();
-
-	void queryComtikaRefund(Map<String, Object> map);
-
-	RespWrapper<Object> uploadPhoto(MultipartFile file);
-
-	RespWrapper<Object> queryMerchant(Long merchantId);
-
-}
+package com.comtika.ctkcloud.server.service.comtika;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.beetl.sql.core.engine.PageQuery;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.comtika.ctkcloud.common.result.RespWrapper;
+import com.comtika.ctkcloud.server.entity.MybankPay;
+import com.comtika.ctkcloud.server.entity.comtikawechat.ComtikaRegisterMerchant;
+import com.comtika.ctkcloud.server.entity.comtikawechat.SysComtikaMerchant;
+import com.comtika.ctkcloud.server.entity.order.CtkRechargeOrder;
+
+public interface ComtikaMerchantService {
+
+	RespWrapper<Object> weChatRegisterMerchant(ComtikaRegisterMerchant comtikaRegisterMerchant);
+
+	RespWrapper<Object> queryWeChatRegisterMerchant(String businessCode);
+
+	RespWrapper<Object> jsapiUnifiedOrder(MybankPay mybankPay, String ip,Long userId);
+
+	void notify(HttpServletResponse response, HttpServletRequest request);
+
+	RespWrapper<Object> comtikaPrePay(MybankPay mybankPay, Long userId,String ip,String uCode);
+
+	RespWrapper<Object> refundComtika(Long rechargeOrderId,String payOrderId, Long refundAmount,Long merchantId,Long customerId);
+
+	RespWrapper<Object> comtikaOrderNotice(CtkRechargeOrder ctk);
+
+	void comtikaOrderNotice();
+
+	void queryComtikaRefund(Map<String, Object> map);
+
+	RespWrapper<Object> uploadPhoto(MultipartFile file);
+
+	RespWrapper<Object> queryMerchant(Long merchantId);
+
+	RespWrapper<Object> comtikaSubLedgerBill(SysComtikaMerchant sysComtikaMerchant, String billDate);
+
+	RespWrapper<Object> queryComtikaBill(PageQuery<Map<String, Object>> pageQery);
+
+	RespWrapper<Object> queryComtikaBillUser(PageQuery<Map<String, Object>> pageQery);
+
+}

+ 97 - 17
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/service/comtika/impl/ComtikaMerchantServiceImpl.java

@@ -14,6 +14,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.beetl.sql.core.engine.PageQuery;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
@@ -29,8 +30,12 @@ import com.comtika.ctkcloud.common.result.RespWrapper;
 import com.comtika.ctkcloud.common.util.IDUtil;
 import com.comtika.ctkcloud.common.util.StringUtil;
 import com.comtika.ctkcloud.server.base.UnifyPayModel;
+import com.comtika.ctkcloud.server.config.ComtikaWechatClientProperties;
+import com.comtika.ctkcloud.server.config.ComtikaWechatProperties;
 import com.comtika.ctkcloud.server.core.ComtikaHttpsUtil;
+import com.comtika.ctkcloud.server.dao.comtika.SysComtikaBillDao;
 import com.comtika.ctkcloud.server.dao.comtika.SysComtikaMerchantDao;
+import com.comtika.ctkcloud.server.dao.comtika.SysComtikaSubUserDao;
 import com.comtika.ctkcloud.server.dao.customer.CtkCustomerDao;
 import com.comtika.ctkcloud.server.dao.pay.PrePayDao;
 import com.comtika.ctkcloud.server.dao.refund.RefundDao;
@@ -38,6 +43,9 @@ import com.comtika.ctkcloud.server.dao.sepAccount.ReceiveDao;
 import com.comtika.ctkcloud.server.entity.DaFeng;
 import com.comtika.ctkcloud.server.entity.MybankPay;
 import com.comtika.ctkcloud.server.entity.NotifyOrder;
+import com.comtika.ctkcloud.server.entity.comtikapay.SubLedgerBill;
+import com.comtika.ctkcloud.server.entity.comtikapay.SysComtikaBill;
+import com.comtika.ctkcloud.server.entity.comtikapay.SysComtikaSubUser;
 import com.comtika.ctkcloud.server.entity.comtikawechat.ComtikaRegisterMerchant;
 import com.comtika.ctkcloud.server.entity.comtikawechat.SysComtikaMerchant;
 import com.comtika.ctkcloud.server.entity.customer.CtkCustomer;
@@ -78,6 +86,14 @@ public class ComtikaMerchantServiceImpl implements ComtikaMerchantService {
 	@Autowired
 	private CtkCustomerDao ctkCustomerDao;
 	
+	@Autowired
+	private SysComtikaBillDao sysComtikaBillDao;
+	
+	@Autowired
+	private SysComtikaSubUserDao sysComtikaSubUserDao;
+	
+	@Autowired
+	private ComtikaWechatProperties comtikaWechatProperties;
 
 	//public static String host = "http://127.0.0.1:8888";
 	public static String host = "https://www.comtikaiot.cn/wechatpay";
@@ -98,6 +114,7 @@ public class ComtikaMerchantServiceImpl implements ComtikaMerchantService {
 	
 	public static  String CTK_SEP_HANDLE_URL = "/sepAccount/sepAccountHandle";//发起分账接口
 	
+	public static String comtikaSubLedgerBill = "/wxpay/jsapi/querySubLedgerBill";
 	
 	@SuppressWarnings("unchecked")
 	@Override
@@ -380,9 +397,9 @@ System.out.println("查询订单信息返回结果:"+data.isSuccess()+"data:"+
 	}
 
 	@Override
-	public RespWrapper<Object> comtikaPrePay(MybankPay mybankPay, Long userId,
-			String ip) {
+	public RespWrapper<Object> comtikaPrePay(MybankPay mybankPay, Long userId,String ip,String uCode) {
 		try {
+System.out.println("uCode的值:" + uCode);
 			if (mybankPay == null)return RespWrapper.makeFailResp("入参不能为空");
 			if (mybankPay.getTotalFee() < 0)return RespWrapper.makeFailResp("支付金额不能小于最小值");
 			System.out.println("入参:" + mybankPay.toString());
@@ -390,6 +407,16 @@ System.out.println("查询订单信息返回结果:"+data.isSuccess()+"data:"+
 			// 查询康体佳的商户号
 			SysComtikaMerchant comtika = new SysComtikaMerchant();
 			comtika.setMerchantId(1L);
+			if(!StringUtil.isEmpty(uCode)){
+				ComtikaWechatClientProperties[] comtikaProperties = comtikaWechatProperties.getClients();
+				for (ComtikaWechatClientProperties comtikaWechatClientProperties : comtikaProperties) {
+					System.out.println("商户id值为:" + comtikaWechatClientProperties.getPayMchid());
+					if(uCode.equals(comtikaWechatClientProperties.getAppCode())){
+						Long comtikaMerchantId = Long.parseLong(comtikaWechatClientProperties.getPayMchid());
+						comtika.setMerchantId(comtikaMerchantId);
+					}
+				}
+			}
 			comtika.setRegisterStatus(2);
 			comtika = sysComtikaMerchantDao.templateOne(comtika);
 			if (comtika == null) {
@@ -400,7 +427,7 @@ System.out.println("查询订单信息返回结果:"+data.isSuccess()+"data:"+
 			UnifyPayModel payModel = UnifyPayModel.valueOf(mybankPay.getPayModel());
 			CtkRechargeOrder order = new CtkRechargeOrder();
 			// 如果不是在线充电,订单关联到康体佳
-			order.setMerchantId(1L);
+			order.setMerchantId(comtika.getMerchantId());
 			order.setCustomerId(userId);
 			order.setCreateTime(startTime);
 			// 30分中支付时间 过期时间
@@ -579,20 +606,6 @@ System.out.println("分账结果返回:" + str);
 		}
 	}
 	
-	public static void main(String[] args) {
-		Map<String, Object> map = new HashMap<String, Object>();
-		map.put("id", "14020");
-		map.put("outRefundNo", "comtika_tui_1591074564673");
-		map.put("refundFee", "1");
-		map.put("rechargeOrderId", "51783");
-		map.put("merchantId", "408");
-		map.put("status", "0");
-		map.put("createTime", "1591074564673");
-		map.put("refundOrderNo", "50300604602020060200815797491");
-		map.put("channelType", "3");
-		ComtikaMerchantServiceImpl a = new ComtikaMerchantServiceImpl();
-		a.queryComtikaRefund(map);
-	}
 	
 	@SuppressWarnings("unchecked")
 	@Override
@@ -746,6 +759,73 @@ System.out.println("发起微信分账,分账结果:" + str1);
 		
 	}
 
+	@SuppressWarnings("unchecked")
+	@Override
+	public RespWrapper<Object> comtikaSubLedgerBill(SysComtikaMerchant sysComtikaMerchant, String billDate) {
+		try {
+			// 请求服务商平台
+			String httpData = ComtikaHttpsUtil.doGet(host + comtikaSubLedgerBill + "?billDate=" + billDate + "&subMchid="+sysComtikaMerchant.getSubMchid());
+			RespWrapper<Object> data = JSONObject.parseObject(httpData,RespWrapper.class);
+			if(data != null && data.isSuccess()){
+				SubLedgerBill slb =  JSONObject.parseObject(data.getData().toString(),SubLedgerBill.class);
+				SysComtikaBill sysComtikaBill = new SysComtikaBill();
+				sysComtikaBill.setMerchantName(sysComtikaMerchant.getMerchantName());
+				sysComtikaBill.setMerchantId(sysComtikaMerchant.getMerchantId());
+				slb.assignmentSysComtikaBill(sysComtikaBill);
+				sysComtikaBillDao.insertTemplate(sysComtikaBill, true);
+				List<SysComtikaSubUser> list = slb.getList();
+				if(null != list && !list.isEmpty()){
+					for (SysComtikaSubUser sysComtikaSubUser : list) {
+						sysComtikaSubUser.setSysComtikaBillId(sysComtikaBill.getId());
+					}
+					sysComtikaSubUserDao.insertBatch(list);
+				}
+				System.out.println(slb);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			return RespWrapper.makeErrorResp("服务器错误!");
+		}
+		return RespWrapper.makeSuccessResp("查询分账账单成功!");
+	}
+	
+	
+	
+	public static void main(String[] args) throws Exception {
+		String httpData = ComtikaHttpsUtil.doGet(host + comtikaSubLedgerBill + "?billDate=2020-06-03&subMchid=1596395521");
+		System.out.println(httpData);
+		RespWrapper<Object> data = JSONObject.parseObject(httpData,RespWrapper.class);
+		if(data != null && data.isSuccess()){
+			SubLedgerBill a =  JSONObject.parseObject(data.getData().toString(),SubLedgerBill.class);
+			System.out.println(a);
+		}
+		System.out.println(data.toString());
+	}
+
+	@Override
+	public RespWrapper<Object> queryComtikaBill(PageQuery<Map<String, Object>> pageQery) {
+		
+		try {
+			pageQery = sysComtikaBillDao.queryComtikaBill(pageQery);
+			return RespWrapper.makeSuccessResp(pageQery);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return RespWrapper.makeErrorResp("服务器错误!");
+		}
+		
+	}
+
+	@Override
+	public RespWrapper<Object> queryComtikaBillUser(PageQuery<Map<String, Object>> pageQery) {
+		try {
+			pageQery = sysComtikaSubUserDao.queryComtikaBillUser(pageQery);
+			return RespWrapper.makeSuccessResp(pageQery);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return RespWrapper.makeErrorResp("服务器错误!");
+		}
+		
+	}
 	
 
 }

+ 48 - 2
ctkcloud-mybank-service/src/main/java/com/comtika/ctkcloud/server/web/ComtikaController.java

@@ -1,6 +1,8 @@
 package com.comtika.ctkcloud.server.web;
 
 
+import java.util.Map;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -8,17 +10,22 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 
+import org.beetl.sql.core.engine.PageQuery;
 import org.springframework.beans.factory.annotation.Autowired;
 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 org.springframework.web.multipart.MultipartFile;
 
 import com.comtika.ctkcloud.common.base.action.BaseController;
 import com.comtika.ctkcloud.common.result.RespWrapper;
+import com.comtika.ctkcloud.common.util.StringUtil;
+import com.comtika.ctkcloud.server.dao.comtika.SysComtikaMerchantDao;
 import com.comtika.ctkcloud.server.entity.MybankPay;
 import com.comtika.ctkcloud.server.entity.comtikawechat.ComtikaRegisterMerchant;
+import com.comtika.ctkcloud.server.entity.comtikawechat.SysComtikaMerchant;
 import com.comtika.ctkcloud.server.service.comtika.ComtikaMerchantService;
 
 @Api(value = "")
@@ -29,6 +36,8 @@ public class ComtikaController extends BaseController{
 	@Autowired
 	private ComtikaMerchantService comtikaMerchantService;
 	
+	@Autowired
+	private SysComtikaMerchantDao sysComtikaMerchantDao;
 	
 	/**
 	 * 商户进件
@@ -79,11 +88,11 @@ public class ComtikaController extends BaseController{
 	@ApiOperation(value = "这个是钱包充值", notes = "这个是钱包充值")
     @ApiImplicitParam(name = "mybankPay", value = "支付参数", required = false, dataType = "MybankPay")
     @PostMapping("/comtikaPrePay")
-    public RespWrapper<Object> daFengPrePay(@RequestBody MybankPay mybankPay){
+    public RespWrapper<Object> daFengPrePay(@RequestBody MybankPay mybankPay,@RequestParam(required=false,value="uCode") String uCode){
         Long userId = super.getCurrentIdByHead();
         String ip = super.getIpAddrForwardedIp();
         if(userId == null)return RespWrapper.makeUnLoginResp("token无效,您可以尝试重新登录后再试!");
-        return comtikaMerchantService.comtikaPrePay(mybankPay,userId,ip);
+        return comtikaMerchantService.comtikaPrePay(mybankPay,userId,ip,uCode);
     }
 	
 	
@@ -98,4 +107,41 @@ public class ComtikaController extends BaseController{
     public RespWrapper<Object> queryMerchant(Long merchantId) {
 		return comtikaMerchantService.queryMerchant(merchantId);
 	}
+	
+	@ApiOperation(value = "分账账单", notes = "分账账单")
+	@PostMapping("/queryComtikaSubLedgerBill")
+    public RespWrapper<Object> queryComtikaSubLedgerBill(String billDate , String subMchid) {
+		if(StringUtil.isEmpty(billDate) || StringUtil.isEmpty(subMchid)){
+			return RespWrapper.makeFailResp("参数有误,请检查!");
+		}
+		SysComtikaMerchant sys = new SysComtikaMerchant();
+		sys.setSubMchid(subMchid);
+		sys = sysComtikaMerchantDao.templateOne(sys);
+		if( null == sys){
+			return RespWrapper.makeFailResp("特邀商户不存在,请检查!");
+		}
+		return comtikaMerchantService.comtikaSubLedgerBill(sys,billDate);
+	}
+	
+	
+	@ApiOperation(value = "云平台查询分账账单", notes = "云平台查询分账账单")
+	@PostMapping("/queryComtikaBill")
+    public RespWrapper<Object> queryComtikaBill(Long merchantId) {
+		PageQuery<Map<String, Object>> pageQery = super.getPageQuery(false);
+        pageQery.setPara("merchantId",merchantId);
+		return comtikaMerchantService.queryComtikaBill(pageQery);
+	}
+	
+	
+	@ApiOperation(value = "云平台查询分账账单详情", notes = "云平台查询分账账单详情")
+	@PostMapping("/queryComtikaBillUser")
+    public RespWrapper<Object> queryComtikaBillUser(Long id) {
+		if( id == null){
+			return RespWrapper.makeFailResp("参数有误,请检查!");
+		}
+		PageQuery<Map<String, Object>> pageQery = super.getPageQuery(false);
+        pageQery.setPara("id",id);
+		return comtikaMerchantService.queryComtikaBillUser(pageQery);
+	}
+	
 }

+ 33 - 0
ctkcloud-mybank-service/src/main/resources/sql/comtika/sysComtikaBillDao.md

@@ -0,0 +1,33 @@
+queryComtikaBill
+===
+SELECT 
+  #page("scb.*,t.merchant_abbr")#
+FROM
+  sys_comtika_bill scb 
+  LEFT JOIN 
+    (SELECT 
+      merchant_abbr,
+      merchant_id 
+    FROM
+      ctk_merchant_detail 
+    WHERE 1 = 1
+@if(!isEmpty(merchantId)){
+    AND merchant_id = #merchantId#
+@}
+) t
+    ON t.merchant_id = scb.merchant_id 
+WHERE 1 = 1
+@if(!isEmpty(merchantId)){
+    AND scb.merchant_id = #merchantId#
+@}
+@if(!isEmpty(endTime)){
+    AND scb.bill_date <= #endTime#
+@}
+@if(!isEmpty(startTime)){
+    AND scb.bill_date >= #startTime#
+@}    
+    
+    
+
+
+

+ 9 - 0
ctkcloud-mybank-service/src/main/resources/sql/comtika/sysComtikaSubUserDao.md

@@ -0,0 +1,9 @@
+queryComtikaBillUser
+===
+SELECT 
+  #page(" t.* ")# 
+FROM
+  sys_comtika_sub_user t 
+WHERE sys_comtika_bill_id = #id#
+
+