|
@@ -5,6 +5,7 @@ import com.jfinal.plugin.activerecord.Db;
|
|
|
import com.jfinal.plugin.activerecord.Model;
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
+import com.mall.model.merchant.Merchant;
|
|
|
import com.mall.util.DateUtil;
|
|
|
import com.mall.util.Utility;
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
@@ -266,10 +267,20 @@ public class Product extends Model<Product>
|
|
|
sql.append(" t.product_main_img,");
|
|
|
sql.append(" (select ifnull(sum(a.product_qty),0) from user_order a,user_order_detail b where ");
|
|
|
sql.append(" a.id =b.order_id and b.product_id = t.id and (order_status='20' or order_status='30' or order_status='40')) sale_num");
|
|
|
- sql.append(" from product t where (t.product_type='10' or t.product_type='30') and t.product_owner='10' and t.status='1' and t.time_status=0");
|
|
|
+ sql.append(" from product t where (t.product_type='10' or t.product_type='30') and t.status='1' and t.time_status=0");
|
|
|
if(StringUtils.isNotEmpty(id)){
|
|
|
sql.append(" and t.id !="+id);
|
|
|
- }
|
|
|
+ Product product = this.findById(id);
|
|
|
+ Merchant merchant = Merchant.dao.findById(product.getInt("merchant_id"));
|
|
|
+ if("1".equals(merchant.get("is_shop"))){
|
|
|
+ sql.append(" and t.product_owner='20' and t.merchant_id ="+product.getInt("merchant_id"));
|
|
|
+ }else {
|
|
|
+ sql.append(" and t.product_owner='10'");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ sql.append(" and t.product_owner='10'");
|
|
|
+ }
|
|
|
+
|
|
|
sql.append(" order by t.is_hot desc, t.sort desc");
|
|
|
sql.append(" limit 4");
|
|
|
return find(sql.toString());
|