修复配额客户额外单价显示,优化单价修改
parent
2a95071ed0
commit
6737d9f1c0
|
|
@ -10,13 +10,16 @@ import com.cowr.model.CustomerReceiver;
|
|||
import com.cowr.model.PrepayCustomer;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
|
||||
import com.cowr.ssjygl.supermarket.customerdistance.SupermarketCustomerDistanceService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Apr 06 21:35:28 CST 2020
|
||||
|
|
@ -78,17 +81,17 @@ public class CustomerService extends BaseService {
|
|||
" ) a on a.customer_id = t.id\n" +
|
||||
" \n" +
|
||||
" left join (\n" +
|
||||
" select t.id,"+
|
||||
" t.customer_id,\n"+
|
||||
" t.supermarket_id,\n"+
|
||||
"t.recharge_time,\n"+
|
||||
" t.spend_time,\n"+
|
||||
"t.first_recharge_time,\n"+
|
||||
" t.threshold,\n"+
|
||||
" t.notice,\n"+
|
||||
" (t.surplus-ifnull(m.amount,0)) surplus from prepay_customer t\n"+
|
||||
"left join (select customer_id,ifnull(sum(amount),0) amount from refund_detail where state<3 group by customer_id) m\n"+
|
||||
" on t.customer_id=m.customer_id\n"+
|
||||
" select t.id," +
|
||||
" t.customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
"t.recharge_time,\n" +
|
||||
" t.spend_time,\n" +
|
||||
"t.first_recharge_time,\n" +
|
||||
" t.threshold,\n" +
|
||||
" t.notice,\n" +
|
||||
" (t.surplus-ifnull(m.amount,0)) surplus from prepay_customer t\n" +
|
||||
"left join (select customer_id,ifnull(sum(amount),0) amount from refund_detail where state<3 group by customer_id) m\n" +
|
||||
" on t.customer_id=m.customer_id\n" +
|
||||
" left join (\n" +
|
||||
" select max(t.id) prepay_customer_id, t.customer_id from prepay_customer t\n" +
|
||||
" group by t.customer_id\n" +
|
||||
|
|
@ -167,4 +170,30 @@ public class CustomerService extends BaseService {
|
|||
public List<Customer> list() {
|
||||
return Customer.dao.find("select * from customer");
|
||||
}
|
||||
|
||||
public List<Record> distUnitPriceDistance(int customer_id) {
|
||||
List<Record> list = SupermarketCustomerDistanceService.me.customerDistance(customer_id);
|
||||
List<Record> uplist = Db.find("select * from customer_supermarket_product t where t.customer_id = ? ", customer_id);
|
||||
|
||||
Map<Integer, List<Record>> map = new HashMap<>();
|
||||
for (Record record : uplist) {
|
||||
Integer supermarket_id = record.getInt("supermarket_id");
|
||||
|
||||
if (!map.containsKey(supermarket_id)) {
|
||||
map.put(supermarket_id, new ArrayList<>());
|
||||
}
|
||||
|
||||
map.get(supermarket_id).add(record);
|
||||
}
|
||||
|
||||
for (Record record : list) {
|
||||
Integer supermarket_id = record.getInt("id");
|
||||
|
||||
if (map.containsKey(supermarket_id)) {
|
||||
record.set("UnitPrices", map.get(supermarket_id));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class Config extends JFinalConfig {
|
|||
public static DeviceThread deviceThread = new DeviceThread();
|
||||
public static SocketIOService socketio = null;
|
||||
private static boolean client_run = true;
|
||||
public static final String CLINET_VERSION = "20210923";
|
||||
public static final String CLINET_VERSION = "20210927";
|
||||
|
||||
public static String getRootPath() {
|
||||
return PathKit.getWebRootPath()
|
||||
|
|
|
|||
|
|
@ -151,4 +151,8 @@ public class CustomerController extends Controller {
|
|||
Integer customer_id = getInt("customer_id");
|
||||
renderJson(RefundDetailService.me.getCustomerAccountBalance(customer_id));
|
||||
}
|
||||
public void distUnitPriceDistance(){
|
||||
Integer customer_id = getInt("customer_id");
|
||||
renderJson(Result.object(CustomerService.me.distUnitPriceDistance(customer_id)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cowr.service.ssjygl.supermarket;
|
||||
|
||||
import com.cowr.common.base.BaseModel;
|
||||
import com.cowr.common.enums.Enums;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.*;
|
||||
|
|
@ -58,8 +57,8 @@ public class SupermarketSyncService extends BaseSyncService {
|
|||
@Override
|
||||
public boolean run() {
|
||||
try {
|
||||
boolean ret = false;
|
||||
SyncTask synctask = new SyncTask();
|
||||
boolean ret = false;
|
||||
SyncTask synctask = new SyncTask();
|
||||
SyncTask synctaskstock = new SyncTask(); // 库存的,只发送到对应的超市,其他超市就不需要了
|
||||
|
||||
SupermarketProduct sp = new SupermarketProduct();
|
||||
|
|
@ -154,22 +153,33 @@ public class SupermarketSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
|
||||
public Result editUnitPrice(int supermarket_id, int product_id,Double unit_price, Sysuser sysuser) {
|
||||
public Result editUnitPrice(int supermarket_id, int product_id, Double unit_price, Sysuser sysuser) {
|
||||
if (unit_price == null || unit_price <= 0) {
|
||||
return Result.failed("商品单价不能小于0");
|
||||
}
|
||||
|
||||
SupermarketProduct sp = SupermarketProduct.dao.findByIds(supermarket_id, product_id);
|
||||
BaseModel saveold = (BaseModel) sp.clone();
|
||||
if (sp == null) {
|
||||
return Result.failed("商品配置信息不存在");
|
||||
}
|
||||
if(unit_price==null ||unit_price<=0){
|
||||
return Result.failed("商品单价不能小于0");
|
||||
}
|
||||
|
||||
SupermarketProduct saveold = sp.clone();
|
||||
|
||||
sp.setUnitPrice(BigDecimal.valueOf(unit_price));
|
||||
String sql="select t.* from ordercluster t where t.state<5 and t.supermarket_id=? and product_id=? " +
|
||||
"and t.id not in (select b.id from customer_supermarket_product a," +
|
||||
"ordercluster b where a.customer_id=b.customer_id and a.supermarket_id=b.supermarket_id and a.product_id=b.product_id)";
|
||||
List<Ordercluster> orderclusterList=Ordercluster.dao.find(sql,supermarket_id, product_id);
|
||||
Map<Integer, SyncTask> map = new HashMap<>();
|
||||
if (orderclusterList!=null &&!orderclusterList.isEmpty()) {
|
||||
|
||||
String sql = "select t.* from ordercluster t \n" +
|
||||
" where t.state < 5 \n" +
|
||||
" and t.supermarket_id = ?\n" +
|
||||
" and t.product_id = ?\n" +
|
||||
" and t.customer_id not in (\n" +
|
||||
" select a.customer_id from customer_supermarket_product a\n" +
|
||||
" where a.customer_id = t.customer_id \n" +
|
||||
" and a.supermarket_id = t.supermarket_id \n" +
|
||||
" and a.product_id = t.product_id\n" +
|
||||
" )";
|
||||
List<Ordercluster> orderclusterList = Ordercluster.dao.find(sql, supermarket_id, product_id);
|
||||
Map<Integer, SyncTask> map = new HashMap<>();
|
||||
if (orderclusterList != null && !orderclusterList.isEmpty()) {
|
||||
for (Ordercluster ordercluster : orderclusterList) {
|
||||
ordercluster.setUnitPrice(BigDecimal.valueOf(unit_price));
|
||||
if (!map.containsKey(ordercluster.getId())) {
|
||||
|
|
@ -195,7 +205,7 @@ public class SupermarketSyncService extends BaseSyncService {
|
|||
ret = stock.update();
|
||||
}
|
||||
|
||||
if (orderclusterList!=null &&!orderclusterList.isEmpty()) {
|
||||
if (orderclusterList != null && !orderclusterList.isEmpty()) {
|
||||
int[] editret = Db.batchUpdate(orderclusterList, orderclusterList.size());
|
||||
for (int i : editret) {
|
||||
// 必须是每条 sql 修改一条记录
|
||||
|
|
|
|||
Loading…
Reference in New Issue