<?php
defined("IN_IA") or exit("Access Denied");
global $xcmodule;
$xcmodule = "xc_laundry";
include_once IA_ROOT . "/addons/xc_laundry/common/function.php";
include_once IA_ROOT . "/addons/xc_laundry/common/sdy.php";
class Xc_laundryModuleWxapp extends WeModuleWxapp
{
public function __construct()
{
global $_GPC, $_W;
xc_base($this, $_GPC["op"]);
}
public function doPageUpload()
{
global $_GPC, $_W;
$uniacid = $_W["uniacid"];
$imgname = $_FILES["file"]["name"];
$tmp = $_FILES["file"]["tmp_name"];
$filepath = "../attachment/images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/";
if (!file_exists("../attachment/images/" . $uniacid . "/" . date("Y") . "/")) {
mkdir("../attachment/images/" . $uniacid . "/" . date("Y") . "/");
}
if (!file_exists($filepath)) {
mkdir($filepath);
}
if (move_uploaded_file($tmp, $filepath . $imgname)) {
$url = tomedia("images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/" . $imgname);
if (!empty($_W["setting"]["remote"]["type"]) && $_W["setting"]["remote"]["type"] == 3) {
load()->func("file");
$request = file_remote_upload("images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/" . $imgname);
if ($request) {
$url = $_W["setting"]["remote"]["qiniu"]["url"] . "/images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/" . $imgname;
}
}
echo $url;
} else {
echo "上传失败";
}
}
public function doPageOnlineUpload()
{
global $_GPC, $_W;
$uniacid = $_W["uniacid"];
$imgname = $_FILES["file"]["name"];
$tmp = $_FILES["file"]["tmp_name"];
$filepath = "../attachment/images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/";
if (!file_exists("../attachment/images/" . $uniacid . "/" . date("Y") . "/")) {
mkdir("../attachment/images/" . $uniacid . "/" . date("Y") . "/");
}
if (!file_exists($filepath)) {
mkdir($filepath);
}
if (move_uploaded_file($tmp, $filepath . $imgname)) {
$url = "https://" . $_SERVER["HTTP_HOST"] . "/attachment/images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/" . $imgname;
$upload = IA_ROOT . "/attachment/images/" . $uniacid . "/" . date("Y") . "/" . date("m") . "/" . $imgname;
echo json_encode(array("url" => $url, "upload" => $upload));
} else {
echo "上传失败";
}
}
public function doPageOrderChange()
{
global $_GPC, $_W;
$uniacid = $_W["uniacid"];
$order = pdo_get("xc_laundry_order", array("status" => 1, "id" => $_GPC["id"], "uniacid" => $uniacid));
$order["userinfo"] = json_decode($order["userinfo"], true);
$order["step"] = json_decode($order["step"], true);
$condition = array();
if ($_GPC["name"] == "get_status" && $_GPC["index"] == 1) {
$condition["get_status"] = 1;
if ($order["pay_type"] == 1) {
$order["step"][3] = date("Y-m-d H:i:s");
} else {
if ($order["pay_type"] == 2 || $order["pay_type"] == 3 || $order["pay_type"] == 5) {
$order["step"][4] = date("Y-m-d H:i:s");
}
}
$condition["step"] = json_encode($order["step"]);
if (!empty($_GPC["cha_img"])) {
$condition["cha_img"] = $_GPC["cha_img"];
}
if (!empty($_GPC["cha_status"])) {
$condition["cha_status"] = $_GPC["cha_status"];
if ($condition["cha_status"] == 2 || $condition["cha_status"] == 3) {
$condition["cha_type"] = $_GPC["cha_type"];
$condition["cha_price"] = $_GPC["cha_price"];
if ($condition["cha_status"] == 2 && $condition["cha_type"] == 1) {
$condition["amount"] = round(floatval($order["amount"]) + floatval($condition["cha_price"]), 2);
$userinfo = pdo_get("xc_laundry_userinfo", array("status" => 1, "openid" => $order["openid"], "uniacid" => $uniacid));
if (!empty($userinfo["unionid"]) && !empty($userinfo["uid"]) && $userinfo["bind"] == 1) {
$member = pdo_get("mc_members", array("uid" => $userinfo["uid"]));
if ($member) {
$userinfo["money"] = $member["credit2"];
}
}
$record_data = array();
$record_data["uniacid"] = $order["uniacid"];
$record_data["out_trade_no"] = $order["out_trade_no"];
$record_data["openid"] = $userinfo["openid"];
$record_data["nick"] = $userinfo["nick"];
$record_data["title"] = "补价";
$record_data["amount"] = $condition["cha_price"];
$record_data["money"] = $userinfo["money"];
$record_data["order_type"] = "线下付款";
$record_data["type"] = 2;
$record_data["createtime"] = date("Y-m-d H:i:s");
pdo_insert("xc_laundry_record", $record_data);
} else {
if ($condition["cha_status"] == 3 && $condition["cha_type"] == 1) {
if (floatval($condition["cha_price"]) > floatval($order["amount"])) {
return $this->result(1, "金额不能大于" . floatval($order["amount"]) . "元");
} else {
$condition["amount"] = round(floatval($order["amount"]) - floatval($condition["cha_price"]), 2);
}
$userinfo = pdo_get("xc_laundry_userinfo", array("status" => 1, "openid" => $order["openid"], "uniacid" => $uniacid));
if (!empty($userinfo["unionid"]) && !empty($userinfo["uid"]) && $userinfo["bind"] == 1) {
$member = pdo_get("mc_members", array("uid" => $userinfo["uid"]));
if ($member) {
$userinfo["money"] = $member["credit2"];
}
}
$record_data = array();
$record_data["uniacid"] = $order["uniacid"];
$record_data["out_trade_no"] = $order["out_trade_no"];
$record_data["openid"] = $userinfo["openid"];
$record_data["nick"] = $userinfo["nick"];
$record_data["title"] = "多退";
$record_data["amount"] = $condition["cha_price"];
$record_data["money"] = $userinfo["money"];
$record_data["order_type"] = "线下付款";
$record_data["type"] = 1;
$record_data["createtime"] = date("Y-m-d H:i:s");
pdo_insert("xc_laundry_record", $record_data);
} else {
if ($condition["cha_status"] == 3 && $condition["cha_type"] == 3) {
if (floatval($condition["cha_price"]) > floatval($order["amount"])) {
return $this->result(1, "金额不能大于" . floatval($order["amount"]) . "元");
} else {
$condition["amount"] = round(floatval($order["amount"]) - floatval($condition["cha_price"]), 2);
$userinfo =