dev
parent
7bb36c28b3
commit
3bad26ca6b
|
|
@ -74,4 +74,15 @@ public class MathUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static int getMax(int[] arr) {
|
||||
if (arr == null || arr.length == 0) return 0;
|
||||
int max = arr[0];
|
||||
for (int i = 1; i < arr.length; i++ ) {
|
||||
if (max < arr[i]) {
|
||||
max = arr[i];
|
||||
}
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ public class CustomerStatService {
|
|||
public List<Record> checkAccount(String tm, Integer customer_id, Integer customer_type_id) {
|
||||
String querytm = tm + " 23:59:59";
|
||||
String sql;
|
||||
String selectSql;
|
||||
String tempSql;
|
||||
String customerSql = "";
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
|
|
@ -36,80 +35,63 @@ public class CustomerStatService {
|
|||
customerSql = " and t.customer_id = ? \n";
|
||||
}
|
||||
|
||||
selectSql = "select t.customer_id id,\n" +
|
||||
" c.`name`,\n" +
|
||||
" t.surplus,\n" +
|
||||
" a.total_price,\n" +
|
||||
" a.total_weight,\n" +
|
||||
" a.total_cnt,\n" +
|
||||
" b.amount,\n" +
|
||||
" b.refund_amount,\n" +
|
||||
" b.amount - ifnull(a.total_price,0) - b.refund_amount then_surplus";
|
||||
|
||||
tempSql = " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" +
|
||||
tempSql = " select t.customer_id, sum(t.total_price) total_price, sum(t.weight) total_weight, count(t.sn) total_cnt\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.customer_id is not null\n" +
|
||||
" where t.customer_id is not null\n" +
|
||||
" and t.create_time <= ? \n" +
|
||||
" and t.state = 5\n" +
|
||||
" and t.sale_type = 0\n" +
|
||||
customerSql +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
sql = "select \n" +
|
||||
" t.customer_id id,\n" +
|
||||
" c.`name`,\n" +
|
||||
" t.surplus,\n" +
|
||||
" a.total_price,\n" +
|
||||
" a.total_weight,\n" +
|
||||
" a.total_cnt,\n" +
|
||||
" b.amount,\n" +
|
||||
" b.refund_amount,\n" +
|
||||
" ifnull(p.presell_amount,0) presell_amount,\n" +
|
||||
" b.amount - ifnull(a.total_price,0) - b.refund_amount - ifnull(p.presell_amount,0) then_surplus" +
|
||||
" from prepay_customer t\n" +
|
||||
" left join customer c on c.id= t.customer_id\n" +
|
||||
" left join (\n" + tempSql + " ) a on a.customer_id = t.customer_id\n" +
|
||||
" left join(\n" +
|
||||
" select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" +
|
||||
" from(\n" +
|
||||
" select t.customer_id, sum(t.amount) amount\n" +
|
||||
" from prepay_detail t\n" +
|
||||
" where t.state= 2\n" +
|
||||
" and t.verify_time <= ?\n" +
|
||||
" group by t.customer_id\n" +
|
||||
" ) a\n" +
|
||||
" left join(\n" +
|
||||
" select t.customer_id, sum(t.amount) amount from refund_detail t\n" +
|
||||
" left join (\n" +
|
||||
" select max(t.change_time) confirm_time, t.refund_detail_id \n" +
|
||||
" from refund_detail_state_history t \n" +
|
||||
" where t.state = 3 \n" +
|
||||
" group by t.refund_detail_id\n" +
|
||||
" ) a on t.id = a.refund_detail_id\n" +
|
||||
" where t.state = 3\n" +
|
||||
" and a.confirm_time <= ?\n" +
|
||||
" group by t.customer_id\n" +
|
||||
" ) b on b.customer_id= a.customer_id\n" +
|
||||
" ) b on b.customer_id= t.customer_id\n" +
|
||||
" left join (select customer_id, ifnull(sum(presell_amount), 0) presell_amount from presell_order where del = 0 group by customer_id) p\n" +
|
||||
" on p.customer_id = t.customer_id\n";
|
||||
|
||||
if (customer_id != null) {
|
||||
paraList.add(querytm);
|
||||
paraList.add(customer_id);
|
||||
paraList.add(querytm);
|
||||
paraList.add(customer_id);
|
||||
paraList.add(querytm);
|
||||
paraList.add(customer_id);
|
||||
paraList.add(customer_id);
|
||||
|
||||
sql = selectSql +
|
||||
" from prepay_customer t\n" +
|
||||
" left join customer c on c.id= t.customer_id\n" +
|
||||
" left join(\n" +
|
||||
tempSql +
|
||||
" ) a on a.customer_id = t.customer_id\n" +
|
||||
" left join(\n" +
|
||||
" select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" +
|
||||
" from(\n" +
|
||||
" select t.customer_id, sum(t.amount) amount\n" +
|
||||
" from prepay_detail t\n" +
|
||||
" where t.state= 2\n" +
|
||||
" and t.verify_time <= ?\n" +
|
||||
" and t.customer_id = ? \n" +
|
||||
" group by t.customer_id\n" +
|
||||
" ) a\n" +
|
||||
" left join(\n" +
|
||||
" select t.customer_id, sum(t.amount) amount from refund_detail t\n" +
|
||||
" left join (\n" +
|
||||
" select max(t.change_time) confirm_time, t.refund_detail_id \n" +
|
||||
" from refund_detail_state_history t \n" +
|
||||
" where t.state = 3 \n" +
|
||||
" group by t.refund_detail_id\n" +
|
||||
" ) a on t.id = a.refund_detail_id\n" +
|
||||
" where t.state = 3\n" +
|
||||
" and a.confirm_time <= ?\n" +
|
||||
" and t.customer_id = ? \n" +
|
||||
" group by t.customer_id\n" +
|
||||
" ) b on b.customer_id= a.customer_id\n" +
|
||||
" ) b on b.customer_id= t.customer_id\n" +
|
||||
" where t.customer_id = ? \n" +
|
||||
" order by t.customer_id";
|
||||
String _sql = " select g.* from (\n" + sql + "\n) g where g.id = ?";
|
||||
|
||||
String _sql = " select \n" +
|
||||
" s.id, \n" +
|
||||
" s.`name`, \n" +
|
||||
" s.surplus, \n" +
|
||||
" s.total_price, \n" +
|
||||
" s.total_weight, \n" +
|
||||
" s.total_cnt, \n" +
|
||||
" s.amount, \n" +
|
||||
" s.refund_amount, \n" +
|
||||
" ifnull(sum(p.presell_amount), 0) presell_amount, \n" +
|
||||
" s.then_surplus - ifnull(sum(p.presell_amount), 0) then_surplus\n" +
|
||||
" from ( " + sql + " ) s left join presell_order p on s.id = p.customer_id where p.del = 0 and s.id = ? group by s.id";
|
||||
paraList.add(customer_id);
|
||||
return Db.find(_sql, paraList.toArray());
|
||||
} else {
|
||||
paraList.add(querytm);
|
||||
|
|
|
|||
|
|
@ -314,11 +314,22 @@ public class LocalOrderService {
|
|||
priceTransTotalUpper = ""; // 运输总价大写
|
||||
}
|
||||
} else if (sntype == OrderTypeEnum.TEMP.getTypeid()) {
|
||||
int decimal = 0;
|
||||
int decimal;
|
||||
int total_weight_decimal = 0;
|
||||
int first_weight_decimal = 0;
|
||||
int second_weight_decimal = 0;
|
||||
double total_weight = order.getDouble("weight");
|
||||
if (total_weight > 0 && String.valueOf(total_weight).indexOf(".") > 0) {
|
||||
decimal = MathUtil.getNumberDecimalDigits(total_weight);
|
||||
total_weight_decimal = MathUtil.getNumberDecimalDigits(total_weight);
|
||||
}
|
||||
if (first_weight.compareTo(new BigDecimal(0)) > 0 && String.valueOf(first_weight).indexOf(".") > 0) {
|
||||
first_weight_decimal = MathUtil.getNumberDecimalDigits(first_weight.doubleValue());
|
||||
}
|
||||
if (second_weight.compareTo(new BigDecimal(0)) > 0 && String.valueOf(second_weight).indexOf(".") > 0) {
|
||||
second_weight_decimal = MathUtil.getNumberDecimalDigits(second_weight.doubleValue());
|
||||
}
|
||||
int[] arr = { total_weight_decimal, first_weight_decimal, second_weight_decimal };
|
||||
decimal = MathUtil.getMax(arr);
|
||||
|
||||
goodsNetWeight = String.format("%." + decimal + "f", Math.abs(order.getDouble("weight"))); // 净重
|
||||
goodsTareWeight = String.format("%." + decimal + "f", first_weight); // 皮重
|
||||
|
|
|
|||
|
|
@ -114,13 +114,22 @@ public class InvoiceReceiveSyncService extends BaseSyncService {
|
|||
}
|
||||
receive.setSurplus(0);
|
||||
|
||||
SyncTask synctask = new SyncTask();
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
try {
|
||||
return receive.update()
|
||||
&& SyncTaskService.me.save(new SyncTask().addUpdateData(receive), receive.getSupermarketId()) // 下发到指定的砂站
|
||||
&& ModifyLogService.me.save(receive, oldobj, Enums.DataOpType.UPDATE.getId(), user);
|
||||
boolean ret = receive.update();
|
||||
|
||||
if (!ret){
|
||||
return false;
|
||||
}
|
||||
|
||||
synctask.addUpdateData(receive);
|
||||
SyncTaskService.me.save(synctask, receive.getSupermarketId());
|
||||
|
||||
return ModifyLogService.me.save(receive, oldobj, Enums.DataOpType.UPDATE.getId(), user);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
|
|
@ -128,6 +137,10 @@ public class InvoiceReceiveSyncService extends BaseSyncService {
|
|||
}
|
||||
});
|
||||
|
||||
if(ret){
|
||||
SyncTaskService.me.send(synctask);
|
||||
}
|
||||
|
||||
return ret ? Result.object(receive) : Result.failed(false, "回收失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,13 +111,22 @@ public class TicketReceiveSyncService extends BaseSyncService {
|
|||
}
|
||||
receive.setSurplus(0);
|
||||
|
||||
SyncTask syncTask = new SyncTask();
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
try {
|
||||
return receive.update()
|
||||
&& SyncTaskService.me.save(new SyncTask().addUpdateData(receive), receive.getSupermarketId()) // 下发到指定的砂站
|
||||
&& ModifyLogService.me.save(receive, oldobj, Enums.DataOpType.UPDATE.getId(), user);
|
||||
boolean ret = receive.update();
|
||||
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
syncTask.addUpdateData(receive);
|
||||
SyncTaskService.me.save(syncTask, receive.getSupermarketId());
|
||||
|
||||
return ModifyLogService.me.save(receive, oldobj, Enums.DataOpType.UPDATE.getId(), user);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
|
|
@ -125,6 +134,10 @@ public class TicketReceiveSyncService extends BaseSyncService {
|
|||
}
|
||||
});
|
||||
|
||||
if (ret) {
|
||||
SyncTaskService.me.send(syncTask);
|
||||
}
|
||||
|
||||
return ret ? Result.object(receive) : Result.failed(false, "回收失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue