手动生成账单

This commit is contained in:
易焱 2020-02-08 22:59:12 +08:00
parent c649ed7a35
commit 956227c10c
5 changed files with 81 additions and 3 deletions

View File

@ -2317,4 +2317,20 @@ public class AdminAction {
return false;
}
/**
* 账单生成
* @param billMonth
* @return
*/
@RequestMapping("/billGen.do")
@ResponseBody
public Object billGen(String billMonth) {
try {
return adminService.billGen(billMonth);
} catch (Exception e) {
log.error("sendMsgToShops:error message:{}", e.toString());
}
return false;
}
}

View File

@ -331,5 +331,7 @@ public interface AdminService {
//随机发送问题给10个商家
public boolean sendMsgToShops(Integer questionId);
//账单生成
boolean billGen(String month);
}

View File

@ -37,6 +37,8 @@ public interface FactoryService {
//获取厂家下的设备总数量
int getDeviceCountByFactory(String factoryCode);
int getDeviceCountByFactory(String factoryCode, String billMonth);
FactoryList get(String id);
List<FactoryList> getFactoryList();

View File

@ -17,6 +17,7 @@ import com.alibaba.fastjson.JSON;
import com.ifish.entity.*;
import com.ifish.entity.event.QueueEventBody;
import com.ifish.entity.event.QueueEventEntity;
import com.ifish.service.FactoryService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
@ -3077,4 +3078,55 @@ public class AdminServiceImpl implements AdminService {
return false;
}
@Autowired
private FactoryService factoryService;
@Override
public boolean billGen(String billMonth) {
System.out.println("addPayBill begin ...");
List<FactoryList> factoryList = factoryService.getFactoryList();
for (FactoryList list : factoryList) {
PayBill payBill = new PayBill();
String factoryCode = list.getFactoryCode();
String isTax = list.getIsTax();
int number = factoryService.getDeviceCountByFactory(factoryCode, billMonth);
payBill.setFactoryList(list);
payBill.setIsTax(isTax);
payBill.setPayStatus("0");
payBill.setAuthorizeNumber(number);
PayBillId payBillId = new PayBillId();
payBillId.setBillMonth(billMonth);
payBillId.setFactoryCode(factoryCode);
payBill.setPayBillId(payBillId);
payBill.setPayDate(new Date());
payBill.setCreateTime(new Date());
//支付金额
Integer money = 0;
//数量小于1000,每个收费15元
if (number < 1000) {
money = number * 15;
} //数量1000~5000,每个收费12元
else if (number >= 1000 && number < 5000) {
money = number * 12;
} //数量5000~10000,每个收费10元
else if (number >= 5000 && number < 10000) {
money = number * 10;
} //数量大于10000,每个收费8元
else if (number >= 10000) {
money = number * 8;
}
//数量超过1000的且需要收税的每个收税一元
if (number >= 1000 && isTax.equals(BooleanEnum.YES.getKey())) {
payBill.setPayMoney(money + number);
} else {
payBill.setPayMoney(money);
}
if (number > 0) {
factoryService.savePayBill(payBill);
}
}
System.out.println("addPayBill end ...");
return true;
}
}

View File

@ -63,6 +63,14 @@ public class FactoryServiceImpl implements FactoryService {
return count;
}
@Override
public int getDeviceCountByFactory(String factoryCode, String billMonth) {
String year = billMonth.split("-")[0];
String month = billMonth.split("-")[1];
int count = this.deviceDao.getNumber("SELECT count(1) from tbl_device td where td.is_charge = '0' and td.factory_code = '"+ factoryCode +"' and str_to_date(td.authorize_time,'%Y-%m')='" + year + "-" + month + "-00'");
return count;
}
@Override
public FactoryList get(String id) {
return this.factoryListDao.get(id);
@ -268,8 +276,6 @@ public class FactoryServiceImpl implements FactoryService {
queryList.add(Restrictions.eq("isBlacklist", selectField1));
}
String selectField2 = searchFilter.getSelectField2();
if(selectField2!=null && !selectField2.equals("")){
if ("1".equals(selectField2)) {