commit commons

master
luoyang 6 years ago
parent 7733d8b59d
commit 4b7dbaaaab

@ -23,10 +23,14 @@ public interface ManageAppService {
JSONObject registerClient(JSONObject device, ClientRegisterInfo registery);
void updateClientRegisterInfo(JSONObject device, String clientMoniker, ClientRegisterInfo info);
List<JSONObject> listPartners(JSONObject device, PartnerQuery query);
JSONObject clientDetail(JSONObject device, String clientMoniker);
JSONObject getNewVersion(JSONObject device);
JSONObject getCommons(JSONObject device);
}

@ -1,6 +1,10 @@
package au.com.royalpay.payment.manage.appclient.core.impls;
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeLogMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialBDPrizeRecordMapper;
import au.com.royalpay.payment.manage.mappers.financial.FinancialPartnerCommissionMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ManageDeviceTokenMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
@ -17,10 +21,14 @@ import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@Service
@ -35,9 +43,17 @@ public class ManageAppServiceImp implements ManageAppService {
@Resource
private ClientManager clientManager;
@Resource
private ClientMapper clientMapper;
@Resource
private SignInAccountService signInAccountService;
@Resource
private ManageDeviceTokenMapper manageDeviceTokenMapper;
@Resource
private FinancialBDPrizeRecordMapper financialBDPrizeRecordMapper;
@Resource
private FinancialBDPrizeLogMapper financialBDPrizeLogMapper;
@Resource
private FinancialPartnerCommissionMapper financialPartnerCommissionMapper;
@Override
@ -79,6 +95,14 @@ public class ManageAppServiceImp implements ManageAppService {
return clientManager.registerClient(null, registery, manager);
}
@Override
public void updateClientRegisterInfo(JSONObject device, String clientMoniker, ClientRegisterInfo info) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
clientManager.updateClientRegisterInfo(manager, clientMoniker, info);
}
@Override
public List<JSONObject> listPartners(JSONObject device, PartnerQuery query) {
String clientType = device.getString("client_type");
@ -140,5 +164,65 @@ public class ManageAppServiceImp implements ManageAppService {
return res;
}
@Override
public JSONObject getCommons(JSONObject device) {
String clientType = device.getString("client_type");
manageDeviceSupport.findRegister(clientType);
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
JSONObject countBdClients = clientMapper.countBdApproveClients(manager.getString("manager_id"));
if (countBdClients == null) {
countBdClients = new JSONObject();
countBdClients.put("approving", 0);
countBdClients.put("pass", 0);
countBdClients.put("this_months_pass", 0);
}
JSONObject result;
switch (manager.getIntValue("org_id")) {
case 1:
result = bdCommons(manager);
break;
default:
result = orgCommons(manager);
break;
}
result.putAll(countBdClients);
return result;
}
private JSONObject bdCommons(JSONObject manager) {
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(new Date());
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1));
Date date = monthCal.getTime();
JSONObject totalDetail = new JSONObject();
totalDetail.put("date", DateFormatUtils.format(date, "yyyy-MM"));
totalDetail.put("total_amount", BigDecimal.ZERO);
totalDetail.put("total_prize", BigDecimal.ZERO);
totalDetail.put("total_donation", BigDecimal.ZERO);
totalDetail.put("send_prize", BigDecimal.ZERO);
totalDetail.put("hold_prize", BigDecimal.ZERO);
totalDetail.put("last_punish", BigDecimal.ZERO);
JSONObject report = financialBDPrizeRecordMapper.getReport(DateFormatUtils.format(date, "yyyy-MM"));
if (report != null) {
totalDetail.putAll(financialBDPrizeLogMapper.findByReportAndBDTotal(report.getString("record_id"), manager.getString("manager_id")));
}
return totalDetail;
}
private JSONObject orgCommons(JSONObject manager) {
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(new Date());
monthCal.set(Calendar.MONTH, (monthCal.get(Calendar.MONTH) - 1));
JSONObject total = financialPartnerCommissionMapper.findTotalByOrg(monthCal.get(Calendar.YEAR), monthCal.get(Calendar.MONTH)+1, manager.getString("org_id"));
if (total == null) {
total = new JSONObject();
total.put("total_amount", BigDecimal.ZERO);
total.put("org_prize", BigDecimal.ZERO);
}
total.put("date", DateFormatUtils.format(monthCal.getTime(), "yyyy-MM"));
return total;
}
}

@ -65,6 +65,12 @@ public class ManageAppController {
return manageAppService.registerClient(device, registery);
}
@RequestMapping(value = "/merchant/{clientMoniker}/update", method = RequestMethod.PUT)
public void updatePartnerInfo(@PathVariable String clientMoniker, @RequestBody ClientRegisterInfo info,
@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device) {
manageAppService.updateClientRegisterInfo(device, clientMoniker, info);
}
@RequestMapping(value = "/merchants", method = RequestMethod.GET)
public List<JSONObject> listPartners(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device, PartnerQuery query) {
return manageAppService.listPartners(device, query);
@ -80,6 +86,11 @@ public class ManageAppController {
return manageAppService.getNewVersion(device);
}
@RequestMapping(value = "/commons", method = RequestMethod.GET)
public JSONObject getCommons(@ModelAttribute(CommonConsts.MANAGER_DEVICE) JSONObject device) {
return manageAppService.getCommons(device);
}
}

@ -44,4 +44,6 @@ public interface FinancialPartnerCommissionMapper {
PageList<JSONObject> getClientExtractRecord(@Param("org_id") int orgId, PageBounds pageBounds);
JSONObject findTotalByOrg(@Param("year") int year, @Param("month") int month, @Param("org_id") String orgId);
}

@ -110,4 +110,7 @@ public interface ClientMapper {
List<JSONObject> findByrpayNotNull();
JSONObject countBdApproveClients(@Param("manager_id") String manager_id);
}

@ -16,6 +16,7 @@ import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;

@ -81,4 +81,12 @@
ORDER BY c.year DESC,c.month DESC
</select>
<select id="findTotalByOrg" resultType="com.alibaba.fastjson.JSONObject">
SELECT
SUM(gross_amount) total_amount,
SUM(org_charge) org_prize
FROM financial_partner_commission
WHERE org_id=#{org_id} AND year=#{year} AND month=#{month}
</select>
</mapper>

@ -444,4 +444,15 @@
<select id="findByrpayNotNull" resultType="com.alibaba.fastjson.JSONObject">
select * FROM sys_clients WHERE rpay_enterprise_id != ''
</select>
<select id="countBdApproveClients" resultType="com.alibaba.fastjson.JSONObject">
SELECT SUM(IF(((approve_result=4 AND open_status IS NULL) OR (approve_result=3 AND open_status IS NULL) OR
open_status=1 OR open_status=2 OR open_status=4),1,0)) approving,
SUM(IF((open_status = 5 AND approve_result = 1 AND approve_time IS NOT NULL),1,0)) pass,
SUM(IF((YEAR(approve_time)=YEAR(now()) and MONTH(approve_time)=MONTH(now()) AND approve_result = 1 AND open_status = 5),1,0)) this_months_pass
FROM sys_clients
WHERE
<bind name="manager_id_pattern" value="'%'+manager_id+'%'"/>
bd_user LIKE #{manager_id_pattern} AND is_valid=1;
</select>
</mapper>
Loading…
Cancel
Save