文件
mashangyoujiu/Application/Retail/Controller/SAdvancePaymentController.class.php

120 行
4.7 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
use Think\Controller;
//[1.4.13]
class SAdvancePaymentController extends BaseController{
static $identity; //用户身份
static $showPrice; //店长是否有查看进价权限 1有 2无
static $global_store_jurisdiction; //门店权限
public function _initialize()
{
self::$identity= session("identity");
self::$showPrice = session('global_store_jurisdiction')['showpurch_price'];
self::$global_store_jurisdiction = session('global_store_jurisdiction');
}
public function index()
{
$arr = array(
'AdvanceOperation'=>'/index.php/Retail/SAdvancePayment/AdvanceOperation',
'AdvanceInfo'=>'/index.php/Retail/SAdvancePayment/record',
'exportOperation'=>'/index.php/Retail/SAdvancePayment/export',
);
$authArr = checkFunction($arr);
$this->assign('authArr',$authArr);
$this->assign('showPrice',self::$showPrice);
$this->assign('identity',self::$identity);
$this->assign("global_store_jurisdiction",self::$global_store_jurisdiction);
$this->display();
}
public function AdvanceList()
{
$merchant_id = session("ls_userinfo")['merchantid'];
$store_id = session("storeid");
$data = I("post.");
$supplier_name = $data['supplier_name'];
$page = $data['page'];
$limit = $data['limit'];
if(!empty($supplier_name)){
$where['supplier_name | linkman'] = array('like',"%".$supplier_name."%");
}
$where['merchantid'] = $merchant_id;
$where['store_id'] = $store_id;
$where['status'] = 1;
$res = A("Api/Inventory")->StoreAdvanceList($where,$page,$limit,"id,supplier_name,linkman,phone,address,advance_money");
$this->ajaxReturn($res);
}
/*预付款操作
* @param type 1增加 减少
*/
public function AdvanceOperation()
{
$merchant_id = session("ls_userinfo")['merchantid'];
$store_id = session("storeid");
$operator_id = session("jurisdiction_user")['id'];
$data = I("post.");
$res = A("Api/Inventory")->StoreAdvanceOperation($data,$merchant_id,$store_id,$operator_id);
if($res['status']==1){
//操作日志记录
if($data['type']==1){
$msg='增加预付款';
}else{
$msg='减少预付款';
}
$source = 0;//请求来源: 0pc系统 1小助手
$type = 4;//平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST);//请求参数 json数据
$desc = '预付款操作:'.$msg;//操作行为描述
action_log($source,$type,$request_data,$desc);
//end
}
$this->ajaxReturn($res);
}
//记录
public function record()
{
$SAdvanceModel = D("SAdvancePayment");
$merchant_id = session("ls_userinfo")['merchantid'];
$store_id = session("storeid");
$data = I("post.");
$supplier_id = $data['supplier_id'];
$page = $data['page'];
$limit = $data['limit'];
$where[$SAdvanceModel::SUPPLIER_ID] = $supplier_id;
$where[$SAdvanceModel::MERCHANT_ID] = $merchant_id;
$where[$SAdvanceModel::STORE_ID] = $store_id;
$res = A("Api/Inventory")->StoreRecord($where,$page,$limit,"*");
$this->ajaxReturn($res);
}
public function export()
{
$merchant_id = session("ls_userinfo")['merchantid'];
$store_id = session("storeid");
$data = I("post.");
$supplier_name = $data['supplier_name'];
if(!empty($supplier_name)){
$where['supplier_name | linkman'] = array('like',"%".$supplier_name."%");
}
$where['store_id'] = $store_id;
$where['merchantid'] = $merchant_id;
$where['status'] = 1;
$advanceList = D("SSupplier")->getSelect($where,$page='',$limit='',"id,supplier_name,linkman,phone,address,advance_money");
if($advanceList){
foreach ($advanceList as $key=>&$val){
$val['index'] = $key + 1;
$val['advance_money'] = round($val['advance_money'],2);
}
}
$advanceList = $advanceList?$advanceList:array();
$fileds_name = "预付款导出";
$arr = array(
array('index',"序号"),
array('supplier_name',"供货商"),
array("linkman","联系人"),
array("phone","手机号"),
array("address","地址"),
array("advance_money","预付款金额")
);
$str = $fileds_name.",导出日期为".date("Y-m-d H:i:s",time());
getExcel($fileds_name, $arr, $advanceList, $str);
}
}