lisai17@sina.com 2020-10-20 16:06:27 +08:00
parent dce5d61298
commit 8a53bdfcbf
3 changed files with 11 additions and 33 deletions

View File

@ -1,5 +1,6 @@
package com.cowr.ssjygl.customer.supermarketproduct; package com.cowr.ssjygl.customer.supermarketproduct;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService; import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam; import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result; import com.cowr.common.view.Result;
@ -45,38 +46,9 @@ public class CustomerSupermarketProductService extends BaseService {
} }
public List<Record> getAllSupProduct(Integer customer_id) { public List<Record> getAllSupProduct(Integer customer_id) {
List<Record> list = Db.find("select t.* from customer_supermarket_product t\n" + return Db.find("select t.supermarket_id, t.unit_price from customer_supermarket_product t\n" +
" where t.customer_id = ? ", customer_id); "where t.customer_id = ? \n" +
List<Record> sups = SupermarketService.me.list(); "and t.product_id = ? ", customer_id, Const.DEFAULT_PRODUCT_ID);
// 没有找到特殊的客户单价时,直接返回砂站原始单价
if (!list.isEmpty()) {
Map<String, Record> map = new HashMap<>();
for (Record record : list) {
int supermarket_id = record.getInt("supermarket_id");
int product_id = record.getInt("product_id");
map.put(supermarket_id + "_" + product_id, record);
}
for (Record record : sups) {
int supermarket_id = record.getInt("id");
List<Record> products = record.get("products");
if (products != null && !products.isEmpty()) {
for (Record product : products) {
int product_id = product.getInt("id");
String key = supermarket_id + "_" + product_id;
if (map.containsKey(key)) {
product.set("unit_price", map.get(key).get("unit_price"));
}
}
}
}
}
return sups;
} }
public Result get(CustomerSupermarketProduct model) { public Result get(CustomerSupermarketProduct model) {

View File

@ -71,7 +71,7 @@ public class XiShuiScale extends AbsScale {
String weight = new String(Arrays.copyOfRange(buf, 4, 10)); String weight = new String(Arrays.copyOfRange(buf, 4, 10));
if (!pattern.matcher(weight).matches() || weight.equals("000000")) { if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
log.error("error weight: %s", weight); // log.error("error weight: %s", weight);
if (errCount == 100) { if (errCount == 100) {
break; break;

View File

@ -30,6 +30,12 @@ public class CustomerSupermarketProductSyncService extends BaseSyncService {
CustomerSupermarketProduct old = CustomerSupermarketProduct.dao.findByIds(model.getCustomerId(), model.getSupermarketId(), model.getProductId()); CustomerSupermarketProduct old = CustomerSupermarketProduct.dao.findByIds(model.getCustomerId(), model.getSupermarketId(), model.getProductId());
SupermarketProduct sp = SupermarketProduct.dao.findByIds(model.getSupermarketId(), model.getProductId());
if (sp == null) {
return Result.failed("砂站没有该品类");
}
if (old == null) { if (old == null) {
return super.save(model, sysuser); return super.save(model, sysuser);
} else { } else {