修复配额客户额外单价显示,优化单价修改

dev
lisai17@sina.com 2021-09-27 10:15:40 +08:00
parent 2a95071ed0
commit 6737d9f1c0
4 changed files with 70 additions and 27 deletions

View File

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

View File

@ -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()

View File

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

View File

@ -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.*;
@ -155,18 +154,29 @@ public class SupermarketSyncService extends BaseSyncService {
public Result editUnitPrice(int supermarket_id, int product_id, Double unit_price, Sysuser sysuser) {
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 sp = SupermarketProduct.dao.findByIds(supermarket_id, product_id);
if (sp == null) {
return Result.failed("商品配置信息不存在");
}
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)";
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()) {