|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|